当前位置:网站首页>Implementation of qcustomplot based on qtquick
Implementation of qcustomplot based on qtquick
2022-06-21 11:11:00 【yantuguiguziPGJ】
List of articles
Preface
QtQuick Development needs C++ Basis and JS Basics
Master the necessary C++ The foundation is learning and using QtQuick An important cornerstone of the framework
QCustomPlot What can be done
Can be in QWidget To shine , Draw various charts and curves
It can also be in QtQuick Show off
- be based on QtQuick Of QCustomPlot Realization
- Inherit QQuickPaintedItem class Implement drawing
design sketch



class DDuiBasePlotItem : public QQuickPaintedItem
{
Q_OBJECT
public:
DDuiBasePlotItem( QQuickItem* parent = 0 );
virtual ~DDuiBasePlotItem();
void paint( QPainter* painter );
virtual void initCustomPlotUI(){}
QCustomPlot *getPlot();
protected:
virtual void hoverMoveEvent(QHoverEvent *event);
virtual void mousePressEvent( QMouseEvent* event );
virtual void mouseReleaseEvent( QMouseEvent* event );
virtual void mouseMoveEvent( QMouseEvent* event );
virtual void mouseDoubleClickEvent( QMouseEvent* event );
virtual void wheelEvent( QWheelEvent *event );
void routeMouseEvents( QMouseEvent* event );
void routeWheelEvents( QWheelEvent* event );
public slots:
void graphClicked( QCPAbstractPlottable* plottable );
void onCustomReplot();
void updateCustomPlotSize();
private:
QCustomPlot* m_CustomPlot;
};
///
/// \brief DDuiCTPWidget::connectQuoteServer
/// initialization
///
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
qmlRegisterType<CustomPlotItem>("CustomPlot", 1, 0, "CustomPlotItem");
qmlRegisterType<CustomPlotBarItem>("CustomPlot", 1, 0, "CustomPlotBarItem");
qmlRegisterType<CustomKLine>("CustomPlot", 1, 0, "CustomKLine");//CustomColorMap
qmlRegisterType<CustomColorMap>("CustomPlot", 1, 0, "CustomColorMap");
qmlRegisterType<CustomBarChart>("CustomPlot", 1, 0, "CustomBarChart");
QQmlApplicationEngine engine;
engine.load(QUrl(QLatin1String("qrc:/main.qml")));
return a.exec();
}
QML Aspect implementation
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import QtQuick.XmlListModel 2.0
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("QCustomPlot stay QML Use in ")
SwipeView {
id: swipeView
anchors.fill: parent
currentIndex: tabBar.currentIndex
interactive: false
DDRubberband{
}
PlotView {
}
CustomPlotBar{
}
CustomKLine{
}
CustomColorMap{
}
CustomBarCharts{}
Page {
Label {
text: qsTr("This is implementation of http://www.qcustomplot.com/index.php/support/forum/172\n" +
"Adding random data on 500 ms tick to plot")
anchors.centerIn: parent
}
XmlListModel {
id: xmlModel
source: "qrc:/combox.xml"
query: "/rss/item"
XmlRole { name: "title"; query: "title/string()" }
XmlRole { name: "pubDate"; query: "pubDate/string()" }
}
ComboBox {
textRole: "title"
model: xmlModel
}
}
}
footer: TabBar {
id: tabBar
currentIndex: swipeView.currentIndex
TabButton {
text: qsTr("RubberBand")
}
TabButton {
text: qsTr("Plot")
}
TabButton {
text: qsTr("Bar")
}
TabButton {
text: qsTr("KLine")
}
TabButton {
text: qsTr("ColorMap")
}
TabButton {
text: qsTr("BarChart")
}
TabButton {
text: qsTr("Info")
}
}
}
matters needing attention
* need QCustomPlot Source code
* You need to continue to develop your own charts based on examples
Application scenarios
- convenient QCustomPlot Business migration to QtQuick Above the application
Source file download
Source download link Source code
边栏推荐
- 15+城市道路要素分割应用,用这一个分割模型就够了!
- fix libpng warning: iCCP: Not recognizing known sRGB profile ......
- Performance optimization - image compression, loading and format selection
- ThreadLocal
- 实测:云RDS MySQL性能是自建的1.6倍
- is not allowed to connect to this mysql server
- Simple implementation of Snake game in C language
- 开源FTP 服务器 FileZilla Server
- 第九章Cisco ASA应用NAT
- WPF DataContext usage
猜你喜欢

分解任务

02. Redis Blockbuster: viewing core principles from high-frequency problems

Performance optimization - image compression, loading and format selection

《Feature-metric Loss for Self-supervised Learning of Depth and Egomotion》论文笔记

618掘金数字藏品?Burberry等奢侈品牌鏖战元宇宙

中芯国际据理力争赢了美国诉讼,证明独立自主才能有更长远的发展

The backbone of the top 100 security companies! Meichuang technology was selected into the 2022 China top 100 Digital Security Report

Feature metric loss for self supervised learning of depth and egomotion

Huawei releases wireless innovative products and solutions to build 5gigaverse Society

用map集合或者list集合存放list集合
随机推荐
Starting a prairie fire, Alibaba cloud database "hundred cities gather together" to help small and medium-sized enterprises' digital intelligence transformation
Intel和台积电的先进工艺阻力越来越大,中国芯片有望缩短差距
实测:云RDS MySQL性能是自建的1.6倍
Mqtt of NLog custom target
Dapr advanced-01-debug dapr
The backbone of the top 100 security companies! Meichuang technology was selected into the 2022 China top 100 Digital Security Report
atguigu----条件渲染
Introduction to ThreadPoolExecutor
Mqtt of NLog custom target
There are obvious signs of oversupply of chips, ASML is no longer a pastry, and investment institutions are shorting on a large scale
QML入门到进阶
618掘金数字藏品?Burberry等奢侈品牌鏖战元宇宙
MySQL - library operation
2022年最强八股文《码出八股文-斩出offer线》
Optimisation des performances - compression, chargement et formatage des images
请教下。使用mysql-cdc需要mysql启用什么设置或者功能的保障么,还是说只要有mysql的i
map.values()转为List和ArrayList的复制
The delimiter connects the list string without secondary processing joiner on(). join()&&String. join(“,“, list)
Feature metric loss for self supervised learning of depth and egomotion
Yum source server configuration