Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
G--H
QML基础整合
提交
9bc5e589
Q
QML基础整合
项目概览
G--H
/
QML基础整合
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
QML基础整合
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9bc5e589
编写于
2月 09, 2023
作者:
G--H
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调整文档
上级
5a24752b
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
84 addition
and
66 deletion
+84
-66
Zeng/Zeng.pro
Zeng/Zeng.pro
+5
-5
Zeng/main.cpp
Zeng/main.cpp
+4
-4
Zeng/model-qt/QQuickPaintedItem/ChartView/ZSChartView.cpp
Zeng/model-qt/QQuickPaintedItem/ChartView/ZSChartView.cpp
+32
-32
Zeng/model-qt/QQuickPaintedItem/ChartView/ZSChartView.h
Zeng/model-qt/QQuickPaintedItem/ChartView/ZSChartView.h
+7
-13
Zeng/model-qt/QQuickPaintedItem/ChartView/ZSPropertyHelper.h
Zeng/model-qt/QQuickPaintedItem/ChartView/ZSPropertyHelper.h
+0
-0
Zeng/model-qt/QQuickPaintedItem/Dashboard/ZSDashboard.cpp
Zeng/model-qt/QQuickPaintedItem/Dashboard/ZSDashboard.cpp
+5
-5
Zeng/model-qt/QQuickPaintedItem/Dashboard/ZSDashboard.h
Zeng/model-qt/QQuickPaintedItem/Dashboard/ZSDashboard.h
+24
-0
Zeng/qml.qrc
Zeng/qml.qrc
+2
-2
Zeng/qml/ZSModelComponent.qml
Zeng/qml/ZSModelComponent.qml
+2
-2
Zeng/qml/main.qml
Zeng/qml/main.qml
+1
-1
Zeng/qml/model-qml/graphical/ZSGraphicalControl.qml
Zeng/qml/model-qml/graphical/ZSGraphicalControl.qml
+2
-2
未找到文件。
Zeng/Zeng.pro
浏览文件 @
9bc5e589
...
...
@@ -15,8 +15,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
SOURCES
+=
\
main
.
cpp
\
model
-
qt
/
QQuickPaintedItem
/
ChartView
/
EV
ChartView
.
cpp
\
model
-
qt
/
QQuickPaintedItem
/
Dashboard
/
Dashboard
.
cpp
model
-
qt
/
QQuickPaintedItem
/
ChartView
/
ZS
ChartView
.
cpp
\
model
-
qt
/
QQuickPaintedItem
/
Dashboard
/
ZS
Dashboard
.
cpp
RESOURCES
+=
qml
.
qrc
...
...
@@ -33,9 +33,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
!
isEmpty
(
target
.
path
)
:
INSTALLS
+=
target
HEADERS
+=
\
model
-
qt
/
QQuickPaintedItem
/
ChartView
/
EV
ChartView
.
h
\
model
-
qt
/
QQuickPaintedItem
/
ChartView
/
PropertyHelper
.
h
\
model
-
qt
/
QQuickPaintedItem
/
Dashboard
/
Dashboard
.
h
model
-
qt
/
QQuickPaintedItem
/
ChartView
/
ZS
ChartView
.
h
\
model
-
qt
/
QQuickPaintedItem
/
ChartView
/
ZS
PropertyHelper
.
h
\
model
-
qt
/
QQuickPaintedItem
/
Dashboard
/
ZS
Dashboard
.
h
...
...
Zeng/main.cpp
浏览文件 @
9bc5e589
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include "model-qt/QQuickPaintedItem/ChartView/
EV
ChartView.h"
#include "model-qt/QQuickPaintedItem/Dashboard/Dashboard.h"
#include "model-qt/QQuickPaintedItem/ChartView/
ZS
ChartView.h"
#include "model-qt/QQuickPaintedItem/Dashboard/
ZS
Dashboard.h"
//注册到qml中使用
void
initRegester
()
{
qmlRegisterType
<
Dashboard
>
(
"Zs.model"
,
1
,
0
,
"
Dashboard"
);
qmlRegisterType
<
EVChartView
>
(
"Zs.model"
,
1
,
0
,
"EV
ChartView"
);
qmlRegisterType
<
ZSDashboard
>
(
"Zs.model"
,
1
,
0
,
"ZS
Dashboard"
);
qmlRegisterType
<
ZSChartView
>
(
"Zs.model"
,
1
,
0
,
"ZS
ChartView"
);
}
int
main
(
int
argc
,
char
*
argv
[])
...
...
Zeng/model-qt/QQuickPaintedItem/ChartView/
EV
ChartView.cpp
→
Zeng/model-qt/QQuickPaintedItem/ChartView/
ZS
ChartView.cpp
浏览文件 @
9bc5e589
#include "
EV
ChartView.h"
#include "
ZS
ChartView.h"
#include <QFontMetrics>
#include <QTime>
EVChartView
::
EV
ChartView
(
QQuickItem
*
parent
)
:
ZSChartView
::
ZS
ChartView
(
QQuickItem
*
parent
)
:
QQuickPaintedItem
(
parent
),
_painter
(
nullptr
)
{
setRenderTarget
(
QQuickPaintedItem
::
FramebufferObject
);
...
...
@@ -11,11 +11,11 @@ EVChartView::EVChartView(QQuickItem *parent):
setFlag
(
ItemAcceptsInputMethod
,
true
);
}
EVChartView
::~
EV
ChartView
()
ZSChartView
::~
ZS
ChartView
()
{
}
void
EV
ChartView
::
setLine
(
QStringList
list
)
void
ZS
ChartView
::
setLine
(
QStringList
list
)
{
//选择时间后 读取数据库后传入
if
(
list
.
size
()
<
0
)
return
;
...
...
@@ -59,14 +59,14 @@ void EVChartView::setLine(QStringList list)
update
();
}
void
EV
ChartView
::
clearLine
()
void
ZS
ChartView
::
clearLine
()
{
_vLine
.
clear
();
_vSeeAreaLine
.
clear
();
update
();
}
void
EV
ChartView
::
startTest
()
void
ZS
ChartView
::
startTest
()
{
m_xMin
=
0
;
m_xMax
=
1000
;
...
...
@@ -84,7 +84,7 @@ void EVChartView::startTest()
setLine
(
list
);
}
void
EV
ChartView
::
paint
(
QPainter
*
painter
)
void
ZS
ChartView
::
paint
(
QPainter
*
painter
)
{
_painter
=
painter
;
setFont
();
...
...
@@ -104,27 +104,27 @@ void EVChartView::paint(QPainter *painter)
_painter
->
setClipRect
(
_chartFrame
);
}
void
EV
ChartView
::
hoverEnterEvent
(
QHoverEvent
*
)
void
ZS
ChartView
::
hoverEnterEvent
(
QHoverEvent
*
)
{
}
void
EV
ChartView
::
hoverLeaveEvent
(
QHoverEvent
*
)
void
ZS
ChartView
::
hoverLeaveEvent
(
QHoverEvent
*
)
{
}
void
EV
ChartView
::
hoverMoveEvent
(
QHoverEvent
*
)
void
ZS
ChartView
::
hoverMoveEvent
(
QHoverEvent
*
)
{
}
void
EV
ChartView
::
wheelEvent
(
QWheelEvent
*
)
void
ZS
ChartView
::
wheelEvent
(
QWheelEvent
*
)
{
}
void
EV
ChartView
::
drawHeader
()
void
ZS
ChartView
::
drawHeader
()
{
if
(
m_headerHeight
>
0
&&!
m_headerTxt
.
isEmpty
()){
int
widthOfTitle
=
_painter
->
fontMetrics
().
horizontalAdvance
(
m_headerTxt
);
//.width(m_headerTxt);//字符串显示的像素大小
...
...
@@ -137,7 +137,7 @@ void EVChartView::drawHeader()
}
}
void
EV
ChartView
::
drawFrame
()
void
ZS
ChartView
::
drawFrame
()
{
QVector
<
QLine
>
vLine
;
//top
...
...
@@ -153,7 +153,7 @@ void EVChartView::drawFrame()
_painter
->
drawLines
(
vLine
);
}
void
EV
ChartView
::
drawHorizontalLine
()
void
ZS
ChartView
::
drawHorizontalLine
()
{
_yTickCountTmp
=
m_vTickCount
;
QStringList
list
=
stepZoom
(
_yMinTmp
,
_yMaxTmp
);
...
...
@@ -169,7 +169,7 @@ void EVChartView::drawHorizontalLine()
_painter
->
drawLines
(
vLine
);
}
void
EV
ChartView
::
drawLeftTickLabel
()
void
ZS
ChartView
::
drawLeftTickLabel
()
{
_yTickCountTmp
=
m_vTickCount
;
QStringList
list
=
stepZoom
(
_yMinTmp
,
_yMaxTmp
);
...
...
@@ -191,7 +191,7 @@ void EVChartView::drawLeftTickLabel()
}
}
void
EV
ChartView
::
drawBottomTitle
()
void
ZS
ChartView
::
drawBottomTitle
()
{
//算出xlabel的位置
_yTickCountTmp
=
m_hTickCount
;
...
...
@@ -213,7 +213,7 @@ void EVChartView::drawBottomTitle()
}
}
void
EV
ChartView
::
drawLeftLabel
()
void
ZS
ChartView
::
drawLeftLabel
()
{
_painter
->
translate
(
m_leftDisplayWidth
/
2
-
4
,
_height
/
2
);
_painter
->
rotate
(
270
);
// 旋转
...
...
@@ -229,7 +229,7 @@ void EVChartView::drawLeftLabel()
setFont
();
}
void
EV
ChartView
::
drawVlines
()
void
ZS
ChartView
::
drawVlines
()
{
if
(
_vLine
.
size
()
>
0
){
_painter
->
setPen
(
"blue"
);
...
...
@@ -245,12 +245,12 @@ void EVChartView::drawVlines()
}
}
QStringList
EV
ChartView
::
getCurrentFrame
(
const
QString
&
strframeValue
)
QStringList
ZS
ChartView
::
getCurrentFrame
(
const
QString
&
strframeValue
)
{
return
strframeValue
.
split
(
"&"
);
}
void
EV
ChartView
::
pointScale
(
const
QPoint
&
point
)
void
ZS
ChartView
::
pointScale
(
const
QPoint
&
point
)
{
double
xMinTmp
=
_xMinTmp
,
xMaxTmp
=
_xMaxTmp
,
yMaxTmp
=
_yMaxTmp
,
yMinTmp
=
_yMinTmp
;
double
xWidth
=
(
_width
-
m_leftDisplayWidth
-
m_rightDisplayWidth
);
...
...
@@ -269,11 +269,11 @@ void EVChartView::pointScale(const QPoint &point)
double
xRightWidth
=
xCurrentScaleWidth
*
((
double
)
1
-
xRate
);
double
yTopHeight
=
yCurrentScaleHeight
*
yRate
;
double
yBottomHeight
=
yCurrentScaleHeight
*
((
double
)
1
-
yRate
);
//宽坐标
0-24000
//宽坐标
double
xPointLen
=
_xMaxTmp
-
_xMinTmp
;
double
yPointLen
=
_yMaxTmp
-
_yMinTmp
;
_xMinTmp
=
(
_xMinTmp
+
(
xLeftWidth
-
x
)
*
(
xPointLen
/
xCurrentScaleWidth
));
_xMaxTmp
=
_xMaxTmp
-
(
xRightWidth
-
(
xWidth
-
x
))
*
(
xPointLen
/
xCurrentScaleWidth
);
//高坐标
-8-8
//高坐标
// _yMaxTmp = m_yMax- (yTopHeight-y)*(yPointLen/yCurrentScaleHeight);
// _yMinTmp = m_yMin+(yBottomHeight-(yHeight-y))*(yPointLen/yCurrentScaleHeight);
_yMaxTmp
=
_yMaxTmp
-
(
yTopHeight
-
y
)
*
(
yPointLen
/
yCurrentScaleHeight
);
...
...
@@ -292,7 +292,7 @@ void EVChartView::pointScale(const QPoint &point)
}
void
EV
ChartView
::
pointNarrow
(
const
QPoint
&
point
)
void
ZS
ChartView
::
pointNarrow
(
const
QPoint
&
point
)
{
//缩小后刻度
qDebug
()
<<
"缩小前 xMin:"
<<
_xMinTmp
<<
" 缩小前 xMax:"
<<
_xMaxTmp
;
...
...
@@ -328,7 +328,7 @@ void EVChartView::pointNarrow(const QPoint &point)
_isScale
=
true
;
}
void
EV
ChartView
::
getSeeAreaLine
()
void
ZS
ChartView
::
getSeeAreaLine
()
{
//获取可视区域
_vSeeAreaLine
.
clear
();
...
...
@@ -373,21 +373,21 @@ void EVChartView::getSeeAreaLine()
}
}
double
EV
ChartView
::
initDouble
(
double
&
bRate
)
double
ZS
ChartView
::
initDouble
(
double
&
bRate
)
{
QString
num
=
QString
::
number
(
bRate
,
'f'
,
8
);
//取到不为0的开始 补齐为5 假如为0.0004 则补齐为 0.0005 每次加
return
0.0
;
}
double
EV
ChartView
::
getYScaleValue
()
double
ZS
ChartView
::
getYScaleValue
()
{
_yScaleCount
++
;
if
(
_yScaleCount
<=
0
)
return
1
;
return
_yScale
;
}
double
EV
ChartView
::
getXScaleValue
()
double
ZS
ChartView
::
getXScaleValue
()
{
_xScaleCount
++
;
if
(
_xScaleCount
<=
0
)
return
1
;
...
...
@@ -395,7 +395,7 @@ double EVChartView::getXScaleValue()
return
_xScale
;
}
void
EV
ChartView
::
setFont
()
void
ZS
ChartView
::
setFont
()
{
QFont
font
;
font
.
setPointSize
(
10
);
...
...
@@ -405,7 +405,7 @@ void EVChartView::setFont()
_painter
->
setRenderHint
(
QPainter
::
Antialiasing
);
}
QString
EV
ChartView
::
removeZero
(
double
data
)
QString
ZS
ChartView
::
removeZero
(
double
data
)
{
QString
label
;
QRegExp
reg
;
...
...
@@ -415,7 +415,7 @@ QString EVChartView::removeZero(double data)
return
""
;
}
bool
EV
ChartView
::
isXaxisInt
()
bool
ZS
ChartView
::
isXaxisInt
()
{
double
xLen
=
((
double
)
_xMaxTmp
-
(
double
)
_xMinTmp
)
/
m_hTickCount
;
if
(
isInt
(
xLen
)){
...
...
@@ -436,7 +436,7 @@ bool EVChartView::isXaxisInt()
return
true
;
}
bool
EV
ChartView
::
isInt
(
const
double
&
dData
)
bool
ZS
ChartView
::
isInt
(
const
double
&
dData
)
{
int
nData
=
(
int
)
dData
;
if
(
nData
==
dData
){
...
...
@@ -446,7 +446,7 @@ bool EVChartView::isInt(const double &dData)
}
}
QStringList
EV
ChartView
::
stepZoom
(
double
&
min
,
double
&
max
)
QStringList
ZS
ChartView
::
stepZoom
(
double
&
min
,
double
&
max
)
{
//最小步径
QStringList
list
;
...
...
Zeng/model-qt/QQuickPaintedItem/ChartView/
EV
ChartView.h
→
Zeng/model-qt/QQuickPaintedItem/ChartView/
ZS
ChartView.h
浏览文件 @
9bc5e589
#ifndef
EV
ChartView_H
#define
EV
ChartView_H
#ifndef
ZS
ChartView_H
#define
ZS
ChartView_H
#include <QObject>
#include <QQuickPaintedItem>
#include "PropertyHelper.h"
#include "
ZS
PropertyHelper.h"
#include <QPainter>
#include <QList>
#include <QMutex>
class
EVChartView
:
public
QQuickPaintedItem
class
ZSChartView
:
public
QQuickPaintedItem
{
Q_OBJECT
public:
EV
ChartView
(
QQuickItem
*
parent
=
0
);
~
EV
ChartView
();
ZS
ChartView
(
QQuickItem
*
parent
=
0
);
~
ZS
ChartView
();
AUTO_PROPERTY
(
int
,
vTickCount
,
5
)
AUTO_PROPERTY
(
int
,
hTickCount
,
5
)
...
...
@@ -33,9 +32,7 @@ public:
Q_INVOKABLE
void
setLine
(
QStringList
list
);
Q_INVOKABLE
void
clearLine
();
Q_INVOKABLE
void
startTest
();
//测试数据 支持百万级瞬绘
protected:
void
paint
(
QPainter
*
painter
)
override
;
protected:
...
...
@@ -71,8 +68,6 @@ private:
double
getYScaleValue
();
//获取y放大倍数
double
getXScaleValue
();
//获取x放大倍数
void
setFont
();
//一格小于100操作
private:
QString
removeZero
(
double
data
);
bool
isXaxisInt
();
...
...
@@ -105,7 +100,6 @@ private:
bool
_isScale
=
false
;
int
_yTickCountTmp
=
0
;
int
_xTickCountTmp
=
0
;
};
#endif //
EV
ChartView_H
#endif //
ZS
ChartView_H
Zeng/model-qt/QQuickPaintedItem/ChartView/PropertyHelper.h
→
Zeng/model-qt/QQuickPaintedItem/ChartView/
ZS
PropertyHelper.h
浏览文件 @
9bc5e589
文件已移动
Zeng/model-qt/QQuickPaintedItem/Dashboard/Dashboard.cpp
→
Zeng/model-qt/QQuickPaintedItem/Dashboard/
ZS
Dashboard.cpp
浏览文件 @
9bc5e589
#include "Dashboard.h"
#include "
ZS
Dashboard.h"
#include <qmath.h>
...
...
@@ -12,24 +12,24 @@ const int shortstep = maxv/longstep; //短刻度步长
const
double
startDraw
=
-
135.0
;
//绘制起始角度
const
double
stopDraw
=
270.0
;
//绘制结束角度
Dashboard
::
Dashboard
(
QQuickItem
*
parent
)
:
ZSDashboard
::
ZS
Dashboard
(
QQuickItem
*
parent
)
:
QQuickPaintedItem
(
parent
)
{
Values
=
0
;
}
Dashboard
::~
Dashboard
()
ZSDashboard
::~
ZS
Dashboard
()
{
}
void
Dashboard
::
setValues
(
unsigned
int
&
iValues
)
void
ZS
Dashboard
::
setValues
(
unsigned
int
&
iValues
)
{
Values
=
iValues
;
update
();
}
void
Dashboard
::
paint
(
QPainter
*
painter
)
void
ZS
Dashboard
::
paint
(
QPainter
*
painter
)
{
painter
->
setRenderHint
(
QPainter
::
Antialiasing
);
QPoint
center
(
width
()
/
2
,
height
()
/
2
);
...
...
Zeng/model-qt/QQuickPaintedItem/Dashboard/Dashboard.h
→
Zeng/model-qt/QQuickPaintedItem/Dashboard/
ZS
Dashboard.h
浏览文件 @
9bc5e589
#ifndef
DASHBOARD
_H
#define
DASHBOARD
_H
#ifndef
ZSDashboard
_H
#define
ZSDashboard
_H
#include <QQuickPaintedItem>
#include <QQuickItem>
#include <QPainter>
class
Dashboard
:
public
QQuickPaintedItem
class
ZS
Dashboard
:
public
QQuickPaintedItem
{
Q_OBJECT
public:
Dashboard
(
QQuickItem
*
parent
=
nullptr
);
~
Dashboard
();
ZS
Dashboard
(
QQuickItem
*
parent
=
nullptr
);
~
ZS
Dashboard
();
public:
void
setValues
(
unsigned
int
&
iValues
);
Q_INVOKABLE
void
setValues
(
unsigned
int
&
iValues
);
protected:
void
paint
(
QPainter
*
painter
);
...
...
@@ -21,4 +21,4 @@ private:
qreal
Values
;
};
#endif //
DASHBOARD
_H
#endif //
ZSDashboard
_H
Zeng/qml.qrc
浏览文件 @
9bc5e589
<RCC>
<qresource prefix="/">
<file>qml/main.qml</file>
<file>qml/ModelComponent.qml</file>
<file>qml/model-qml/graphical/GraphicalControl.qml</file>
<file>qml/
ZS
ModelComponent.qml</file>
<file>qml/model-qml/graphical/
ZS
GraphicalControl.qml</file>
</qresource>
</RCC>
Zeng/qml/ModelComponent.qml
→
Zeng/qml/
ZS
ModelComponent.qml
浏览文件 @
9bc5e589
...
...
@@ -16,7 +16,7 @@ Rectangle {
if
(
index
==
0
)
{
modelLoader
.
source
=
"
qrc:/qml/model-qml/graphical/GraphicalControl.qml
"
modelLoader
.
source
=
"
qrc:/qml/model-qml/graphical/
ZS
GraphicalControl.qml
"
}
else
if
(
index
==
1
)
{
...
...
@@ -28,6 +28,6 @@ Rectangle {
id
:
modelLoader
width
:
parent
.
width
height
:
parent
.
height
source
:
"
qrc:/qml/model-qml/graphical/GraphicalControl.qml
"
source
:
"
qrc:/qml/model-qml/graphical/
ZS
GraphicalControl.qml
"
}
}
Zeng/qml/main.qml
浏览文件 @
9bc5e589
...
...
@@ -38,7 +38,7 @@ Window {
}
}
ModelComponent
{
ZS
ModelComponent
{
id
:
modelComponent
width
:
parent
.
width
-
listView
.
width
height
:
parent
.
height
...
...
Zeng/qml/model-qml/graphical/GraphicalControl.qml
→
Zeng/qml/model-qml/graphical/
ZS
GraphicalControl.qml
浏览文件 @
9bc5e589
...
...
@@ -58,11 +58,11 @@ Rectangle{
width
:
parent
.
width
height
:
parent
.
height
-
100
currentIndex
:
listView
.
currentIndex
Dashboard
{
ZS
Dashboard
{
width
:
parent
.
width
height
:
parent
.
height
}
EV
ChartView
{
ZS
ChartView
{
id
:
sddddd
width
:
parent
.
width
height
:
parent
.
height
-
200
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录