update code #1
parent
b2938ff0a7
commit
99b5ad0cb9
@ -1,10 +1,13 @@
|
||||
#include "ClockCounter.h"
|
||||
|
||||
ClockCounter::ClockCounter(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
ClockCounter::ClockCounter(QWidget *parent) : QMainWindow(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
ui.SpliterHourMinute->Init(UDateTimeSpliter::Type::Time);
|
||||
ui.SpliterMinuteSecond->Init(UDateTimeSpliter::Type::Time);
|
||||
ui.SpliterSecondMS->Init(UDateTimeSpliter::Type::Dots);
|
||||
}
|
||||
|
||||
ClockCounter::~ClockCounter()
|
||||
{}
|
||||
{
|
||||
}
|
@ -1,28 +1,215 @@
|
||||
<UI version="4.0" >
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ClockCounterClass</class>
|
||||
<widget class="QMainWindow" name="ClockCounterClass" >
|
||||
<property name="objectName" >
|
||||
<string notr="true">ClockCounterClass</string>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<widget class="QMainWindow" name="ClockCounterClass">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
<width>980</width>
|
||||
<height>269</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>ClockCounter</string>
|
||||
</property> <widget class="QMenuBar" name="menuBar" />
|
||||
<widget class="QToolBar" name="mainToolBar" />
|
||||
<widget class="QWidget" name="centralWidget" />
|
||||
<widget class="QStatusBar" name="statusBar" />
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<widget class="LcdNumber" name="NumHour01">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="LcdNumber" name="NumHour02">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="UDateTimeSpliter" name="SpliterHourMinute" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="UDateTimeSpliter" name="SpliterMinuteSecond" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>410</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="LcdNumber" name="NumMinute02">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>330</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="LcdNumber" name="NumMinute01">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>250</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="UDateTimeSpliter" name="SpliterSecondMS" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>650</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="LcdNumber" name="NumSecond01">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>490</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="LcdNumber" name="NumSecond02">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>570</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="LcdNumber" name="NumMillSec03">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>890</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="LcdNumber" name="NumMillSec01">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>730</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="LcdNumber" name="NumMillSec02">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>810</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="BtnStartTimer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>190</y>
|
||||
<width>181</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>开始计时</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="BtnStopTimer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>290</x>
|
||||
<y>190</y>
|
||||
<width>181</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>停止计时</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="BtnGetPreclickPos">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>540</x>
|
||||
<y>190</y>
|
||||
<width>181</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>获取预点击坐标</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="BtnClearPreclickPos">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>780</x>
|
||||
<y>190</y>
|
||||
<width>181</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>清除预点击坐标</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<layoutDefault spacing="6" margin="11" />
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LcdNumber</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>lcdnumber.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>UDateTimeSpliter</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>udatetimespliter.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="ClockCounter.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</UI>
|
||||
</ui>
|
||||
|
@ -0,0 +1,10 @@
|
||||
#include "PreClick.h"
|
||||
|
||||
PreClick::PreClick(QWidget* parent) : QMainWindow(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
}
|
||||
|
||||
PreClick::~PreClick()
|
||||
{
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include "ui_PreClick.h"
|
||||
|
||||
class PreClick : public QMainWindow
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
PreClick(QWidget* parent = nullptr);
|
||||
~PreClick();
|
||||
|
||||
private:
|
||||
Ui::PreClickWindow ui;
|
||||
};
|
||||
|
@ -0,0 +1,151 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PreClickWindow</class>
|
||||
<widget class="QMainWindow" name="PreClickWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>323</width>
|
||||
<height>382</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QGroupBox" name="PosGetter">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>301</width>
|
||||
<height>181</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>预点击坐标</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<widget class="QTextEdit" name="PosX">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>30</y>
|
||||
<width>111</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>X</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="PosY">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>100</y>
|
||||
<width>111</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>110</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Y</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="BtnGetPos">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>30</y>
|
||||
<width>75</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>获取坐标</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="CountGetter">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>210</y>
|
||||
<width>301</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>预点击次数</string>
|
||||
</property>
|
||||
<widget class="QSpinBox" name="ClickCount">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>30</y>
|
||||
<width>261</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="BtnOK">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>330</y>
|
||||
<width>91</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="BtnCancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>330</y>
|
||||
<width>91</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
#include <QWidget.h>
|
||||
#include <QPainter>
|
||||
#include <QColor>
|
||||
#include <QRect>
|
||||
#include <QLinearGradient>
|
||||
#include <QPolygon>
|
||||
|
||||
class UDateTimeSpliter : public QWidget
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
enum class Type
|
||||
{
|
||||
Date,
|
||||
Dots,
|
||||
Time,
|
||||
Empty
|
||||
};
|
||||
|
||||
struct Triangle
|
||||
{
|
||||
QPolygon Shape;
|
||||
QRect EquallyRect;
|
||||
};
|
||||
private:
|
||||
Type ItemType;
|
||||
QColor TextColor1;
|
||||
QColor TextColor2;
|
||||
QColor Background1;
|
||||
QColor Background2;
|
||||
const int DotSpace = 20;
|
||||
const int DateSpace = 20;
|
||||
const int TimeSpace = 20;
|
||||
const int DateSpliterLineSize = 10;
|
||||
const int DotSpliterCircleSize = 6;
|
||||
const int TimeSpliterCircleSize = 7;
|
||||
const int TimeSpliterCircleSpace = 25;
|
||||
const int DateSpliterTriangleSize = 6;
|
||||
private:
|
||||
Triangle GetTriangle(QPoint start, bool left, int xsize, int ysize);
|
||||
void DrawBackground(QPainter& painter);
|
||||
void DrawDateSpliter(QPainter& painter);
|
||||
void DrawDotsSpliter(QPainter& painter);
|
||||
void DrawTimeSpliter(QPainter& painter);
|
||||
public:
|
||||
UDateTimeSpliter(QWidget* parent = nullptr);
|
||||
public:
|
||||
void Init(Type type, QColor tc1 = QColor(), QColor tc2 = QColor(), QColor bg1 = QColor(), QColor bg2 = QColor());
|
||||
void setTextColor1(QColor color);
|
||||
void setTextColor2(QColor color);
|
||||
void setBackground1(QColor color);
|
||||
void setBackground2(QColor color);
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent* event) override;
|
||||
};
|
||||
|
Loading…
Reference in New Issue