This commit is contained in:
touwoyimuli@gmail.com 2019-08-22 23:21:49 +08:00
parent fbf4d3583c
commit c66ea918b0
8 changed files with 213 additions and 0 deletions

View File

@ -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);

View File

@ -6,6 +6,8 @@ ExQStringFun::ExQStringFun(QWidget* parent) :
ui(new Ui::ExQStringFun)
{
ui->setupUi(this);
setWindowTitle(QObject::tr("QString类的一些常用函数"));
}
ExQStringFun::~ExQStringFun()

View File

@ -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();
}

View File

@ -0,0 +1,34 @@
#ifndef EXQDIALQLCD_H
#define EXQDIALQLCD_H
#include <QWidget>
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

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExQdialQLCD</class>
<widget class="QWidget" name="ExQdialQLCD">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>537</width>
<height>149</height>
</rect>
</property>
<property name="windowTitle">
<string>ExQdialQLCD</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,2">
<item>
<widget class="QDial" name="dial">
<property name="wrapping">
<bool>false</bool>
</property>
<property name="notchesVisible">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLCDNumber" name="lcdNumber"/>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>LCD进制显示</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="raidBtn2">
<property name="text">
<string>二进制</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="raidBtn8">
<property name="text">
<string>八进制</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="raidBtn10">
<property name="text">
<string>十进制</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="raidBtn16">
<property name="text">
<string>十六进制</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -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

11
QtQdialQLCDEx/main.cpp Normal file
View File

@ -0,0 +1,11 @@
#include "ExQdialQLCD.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
ExQdialQLCD w;
w.show();
return a.exec();
}