diff --git a/QtQSliderEx/ExQSlider.cpp b/QtQSliderEx/ExQSlider.cpp index 38ff05d..989e487 100644 --- a/QtQSliderEx/ExQSlider.cpp +++ b/QtQSliderEx/ExQSlider.cpp @@ -7,6 +7,7 @@ ExQSlider::ExQSlider(QWidget *parent) : ui(new Ui::ExQSlider) { ui->setupUi(this); + setWindowTitle(QObject::tr("QSlider的用法")); //设置QSlider的最大值为255 (默认范围为0~100) ui->sliderRed->setMaximum(255); diff --git a/QtQStringFunEx/ExQStringFun.cpp b/QtQStringFunEx/ExQStringFun.cpp index 184a722..2689a46 100644 --- a/QtQStringFunEx/ExQStringFun.cpp +++ b/QtQStringFunEx/ExQStringFun.cpp @@ -6,6 +6,8 @@ ExQStringFun::ExQStringFun(QWidget* parent) : ui(new Ui::ExQStringFun) { ui->setupUi(this); + + setWindowTitle(QObject::tr("QString类的一些常用函数")); } ExQStringFun::~ExQStringFun() diff --git a/QtQdialQLCDEx/ExQdialQLCD.cpp b/QtQdialQLCDEx/ExQdialQLCD.cpp new file mode 100644 index 0000000..05742ec --- /dev/null +++ b/QtQdialQLCDEx/ExQdialQLCD.cpp @@ -0,0 +1,44 @@ +#include "ExQdialQLCD.h" +#include "ui_ExQdialQLCD.h" + +ExQdialQLCD::ExQdialQLCD(QWidget *parent) : + QWidget(parent), + ui(new Ui::ExQdialQLCD) +{ + ui->setupUi(this); + + //notchesVisible:表盘的小刻度是否可见 + //notchTarget:表盘刻度间间隔的像素值 + connect(ui->dial, SIGNAL(valueChanged(int)), this, SLOT(onDisplayLCD(int))); + setWindowTitle(QObject::tr("QDial表盘输入,在LCD以多种进制显示")); +} + +ExQdialQLCD::~ExQdialQLCD() +{ + delete ui; +} + +void ExQdialQLCD::onDisplayLCD(int val) +{ + ui->lcdNumber->display(val); +} + +void ExQdialQLCD::on_raidBtn2_clicked() //设置LCD显示二进制数 +{ + ui->lcdNumber->setBinMode(); +} + +void ExQdialQLCD::on_raidBtn8_clicked() //设置LCD显示八进制数 +{ + ui->lcdNumber->setOctMode(); +} + +void ExQdialQLCD::on_raidBtn10_clicked() //设置LCD显示十进制数 +{ + ui->lcdNumber->setDecMode(); +} + +void ExQdialQLCD::on_raidBtn16_clicked() //设置LCD显示十六进制数 +{ + ui->lcdNumber->setHexMode(); +} diff --git a/QtQdialQLCDEx/ExQdialQLCD.h b/QtQdialQLCDEx/ExQdialQLCD.h new file mode 100644 index 0000000..6a582e8 --- /dev/null +++ b/QtQdialQLCDEx/ExQdialQLCD.h @@ -0,0 +1,34 @@ +#ifndef EXQDIALQLCD_H +#define EXQDIALQLCD_H + +#include + +namespace Ui { +class ExQdialQLCD; +} + +class ExQdialQLCD : public QWidget +{ + Q_OBJECT + +public: + explicit ExQdialQLCD(QWidget *parent = nullptr); + ~ExQdialQLCD(); + +public slots: + void onDisplayLCD(int val); + +private slots: + void on_raidBtn2_clicked(); + + void on_raidBtn8_clicked(); + + void on_raidBtn10_clicked(); + + void on_raidBtn16_clicked(); + +private: + Ui::ExQdialQLCD *ui; +}; + +#endif // EXQDIALQLCD_H diff --git a/QtQdialQLCDEx/ExQdialQLCD.ui b/QtQdialQLCDEx/ExQdialQLCD.ui new file mode 100644 index 0000000..3663fa1 --- /dev/null +++ b/QtQdialQLCDEx/ExQdialQLCD.ui @@ -0,0 +1,79 @@ + + + ExQdialQLCD + + + + 0 + 0 + 537 + 149 + + + + ExQdialQLCD + + + + + + + + false + + + true + + + + + + + + + + + + LCD进制显示 + + + + + + 二进制 + + + + + + + 八进制 + + + + + + + 十进制 + + + true + + + + + + + 十六进制 + + + + + + + + + + + + diff --git a/QtQdialQLCDEx/QT_win_32x32.ico b/QtQdialQLCDEx/QT_win_32x32.ico new file mode 100644 index 0000000..0ee0568 Binary files /dev/null and b/QtQdialQLCDEx/QT_win_32x32.ico differ diff --git a/QtQdialQLCDEx/QtQdialQLCDEx.pro b/QtQdialQLCDEx/QtQdialQLCDEx.pro new file mode 100644 index 0000000..e81ce58 --- /dev/null +++ b/QtQdialQLCDEx/QtQdialQLCDEx.pro @@ -0,0 +1,42 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2019-08-22T21:45:53 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = QtQdialQLCDEx +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + ExQdialQLCD.cpp + +HEADERS += \ + ExQdialQLCD.h + +FORMS += \ + ExQdialQLCD.ui + +RC_ICONS += QT_win_32x32.ico + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/QtQdialQLCDEx/main.cpp b/QtQdialQLCDEx/main.cpp new file mode 100644 index 0000000..2da6046 --- /dev/null +++ b/QtQdialQLCDEx/main.cpp @@ -0,0 +1,11 @@ +#include "ExQdialQLCD.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + ExQdialQLCD w; + w.show(); + + return a.exec(); +}