QtQProgressBarEx
update QtQProgressBarEx
This commit is contained in:
parent
c66ea918b0
commit
2226d98869
36
QtQProgressBarEx/ExQProgressBar.cpp
Normal file
36
QtQProgressBarEx/ExQProgressBar.cpp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#include "ExQProgressBar.h"
|
||||||
|
#include "ui_ExQProgressBaressBarressbar.h"
|
||||||
|
|
||||||
|
ExQProgressBar::ExQProgressBar(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::ExQProgressBar)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
setWindowTitle(QObject::tr("QSlider、QScrollBar、QProgressBar控件的联动"));
|
||||||
|
|
||||||
|
//ui->progressBarHor->setOrient1ation(Qt::Horizontal /*(the default) Qt::Vertical*/); 设置进度条水平或竖直
|
||||||
|
|
||||||
|
connect(ui->sliderHor, SIGNAL(valueChanged(int)), this, SLOT(onValChange(int)));
|
||||||
|
connect(ui->scrollBarHor, SIGNAL(valueChanged(int)), this, SLOT(onValChange(int)));
|
||||||
|
connect(ui->scrollBarHor, SIGNAL(valueChanged(int)), this, SLOT(onValChange(int)));
|
||||||
|
connect(ui->sliderVer, SIGNAL(valueChanged(int)), this, SLOT(onValChange(int)));
|
||||||
|
connect(ui->scrollBarVer, SIGNAL(valueChanged(int)), this, SLOT(onValChange(int)));
|
||||||
|
connect(ui->progressBarVer, SIGNAL(valueChanged(int)), this, SLOT(onValChange(int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
ExQProgressBar::~ExQProgressBar()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
//对应的槽函数
|
||||||
|
void ExQProgressBar::onValChange(int val)
|
||||||
|
{
|
||||||
|
ui->sliderHor->setValue(val);
|
||||||
|
ui->scrollBarHor->setValue(val);
|
||||||
|
ui->progressBarHor->setValue(val);
|
||||||
|
ui->sliderVer->setValue(val);
|
||||||
|
ui->scrollBarVer->setValue(val);
|
||||||
|
ui->progressBarVer->setValue(val);
|
||||||
|
|
||||||
|
}
|
25
QtQProgressBarEx/ExQProgressBar.h
Normal file
25
QtQProgressBarEx/ExQProgressBar.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef EXQPROGRESSBAR_H
|
||||||
|
#define EXQPROGRESSBAR_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class ExQProgressBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ExQProgressBar : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ExQProgressBar(QWidget *parent = nullptr);
|
||||||
|
~ExQProgressBar();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onValChange(int val);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::ExQProgressBar *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EXQPROGRESSBAR_H
|
104
QtQProgressBarEx/ExQProgressBaressBarressbar.ui
Normal file
104
QtQProgressBarEx/ExQProgressBaressBarressbar.ui
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ExQProgressBar</class>
|
||||||
|
<widget class="QWidget" name="ExQProgressBar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>786</width>
|
||||||
|
<height>302</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>ExQProgressBar</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>水平</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QSlider" name="sliderHor">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QScrollBar" name="scrollBarHor">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QProgressBar" name="progressBarHor">
|
||||||
|
<property name="value">
|
||||||
|
<number>24</number>
|
||||||
|
</property>
|
||||||
|
<property name="format">
|
||||||
|
<string>%p%</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Maximum</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
|
<property name="title">
|
||||||
|
<string>竖直</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QSlider" name="sliderVer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QScrollBar" name="scrollBarVer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QProgressBar" name="progressBarVer">
|
||||||
|
<property name="value">
|
||||||
|
<number>24</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
BIN
QtQProgressBarEx/QT_win_32x32.ico
Normal file
BIN
QtQProgressBarEx/QT_win_32x32.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
42
QtQProgressBarEx/QtQProgressBarEx.pro
Normal file
42
QtQProgressBarEx/QtQProgressBarEx.pro
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2019-08-24T14:55:33
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
QT += core gui
|
||||||
|
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
|
TARGET = QtQProgressBarEx
|
||||||
|
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 \
|
||||||
|
ExQProgressBar.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
ExQProgressBar.h
|
||||||
|
|
||||||
|
FORMS += \
|
||||||
|
ExQProgressBaressBarressbar.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
QtQProgressBarEx/main.cpp
Normal file
11
QtQProgressBarEx/main.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "ExQProgressBar.h"
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
ExQProgressBar w;
|
||||||
|
w.show();
|
||||||
|
|
||||||
|
return a.exec();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user