当前位置:网站首页>QT learning 21 standard dialog box in QT (Part 2)
QT learning 21 standard dialog box in QT (Part 2)
2022-07-03 13:58:00 【A little black sauce】
Qt Study 21 Qt Standard dialog boxes in ( Next )
Font dialog
- Qt Provided in predefined Font dialog box QFontDialog class
- QFontDialog Class is used to provide Dialog box part for selecting font

- How to use the font dialog
// Construct font dialog object
QFontDialog dlg(this);
// Set the relevant properties of the font dialog
dlg.setWindowTitle("Font Editor");
dlg.setCurrentFont(QFont("Courier New", 10, QFont::Bold)); // Initial font
if (dlg.exec() == QFontDialog::Accepted) {
qDebug() << dlg.selectedFont();
}
- QFontDialog Utility functions in
- QFontDialog::getFont
Progress dialog
- Qt Provided in predefined Progress dialog box QProgressDialog class
- QProgressDialog Class used Show progress information
- QProgressDialog Class used Occasions that require users to wait

- How to use the progress dialog
// Construction progress dialog object
QProgressDialog dlg(this);
// Set the relevant properties of the progress dialog
dlg.setWindowTitle("Updating...");
dlg.setLabelText("Downloading from server...");
dlg.setMinimum(0); // Set the minimum progress value
dlg.setMaximum(1000); // Set the maximum progress value
dlg.exec();
Code experiments
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QPushButton>
class Widget : public QWidget
{
Q_OBJECT
private:
QPushButton FontDialogBtn;
QPushButton ProgressDialogBtn;
private slots:
void FontDialogBtn_Clicked();
void ProgressDialogBtn_Clicked();
public:
Widget(QWidget *parent = 0);
~Widget();
};
#endif // WIDGET_H
#include "Widget.h"
#include <QFontDialog>
#include <QProgressDialog>
#include <QDebug>
Widget::Widget(QWidget *parent)
: QWidget(parent), FontDialogBtn(this), ProgressDialogBtn(this)
{
FontDialogBtn.setText("Font Dialog");
FontDialogBtn.move(20, 20);
FontDialogBtn.resize(160, 30);
ProgressDialogBtn.setText("Progress Dialog");
ProgressDialogBtn.move(20, 70);
ProgressDialogBtn.resize(160, 30);
resize(200, 120);
setFixedSize(200, 120);
connect(&FontDialogBtn, SIGNAL(clicked()), this, SLOT(FontDialogBtn_Clicked()));
connect(&ProgressDialogBtn, SIGNAL(clicked()), this, SLOT(ProgressDialogBtn_Clicked()));
}
Widget::~Widget()
{
}
void Widget::FontDialogBtn_Clicked()
{
QFontDialog dlg(this);
dlg.setWindowTitle("Font Dialog Test");
dlg.setCurrentFont(QFont("Courier New", 10, QFont::Normal));
if (dlg.exec() == QFontDialog::Accepted) {
qDebug() << dlg.selectedFont();
}
// Simple usage
bool ok;
QFont font= QFont("Courier New", 10, QFont::Normal);
font = QFontDialog::getFont(&ok, font, this);
qDebug() << font;
}
void Widget::ProgressDialogBtn_Clicked()
{
QProgressDialog dlg(this);
dlg.setWindowTitle("Updating...");
dlg.setLabelText("Downloading update from server...");
dlg.setMinimum(0);
dlg.setMaximum(100);
dlg.setValue(35);
// create a new thread
dlg.exec();
}
#include "Widget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}
Summary
- Qt In the standard dialog box Design patterns
- GUI Interface Component generation Data objects
- Business logic Other objects in use Data objects
- GUI Interface And Business logic adopt Data objects Connect

边栏推荐
- Unity Render Streaming通过Js与Unity自定义通讯
- RocksDB LRUCache
- How to promote the progress of project collaboration | community essay solicitation
- [bw16 application] instructions for firmware burning of Anxin Ke bw16 module and development board update
- Implementation of Muduo accept connection, disconnection and sending data
- JVM family - overview, program counter day1-1
- Implementation of Muduo asynchronous logging
- The latest BSC can pay dividends. Any B usdt Shib eth dividend destruction marketing can
- C language standard IO function sorting
- Uniapp tips - scrolling components
猜你喜欢

Uniapp tips - scrolling components

Bidirectional linked list (we only need to pay attention to insert and delete functions)

挡不住了,国产芯片再度突进,部分环节已进到4nm

Mastering the cypress command line options is the basis for truly mastering cypress

Using registered classes to realize specific type matching function template

NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线

Qt学习24 布局管理器(三)

Dlopen() implements dynamic loading of third-party libraries

解决MySql 1045 Access denied for user ‘root‘@‘localhost‘ (using password: YES)

Rasp implementation of PHP
随机推荐
Go language web development series 27: Gin framework: using gin swagger to implement interface documents
Flutter dynamic | fair 2.5.0 new version features
软件测试工作那么难找,只有外包offer,我该去么?
Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware
Analysis of the characteristics of page owner
挡不住了,国产芯片再度突进,部分环节已进到4nm
jvm-类加载
项目协作的进度如何推进| 社区征文
Halcon combined with C # to detect surface defects -- Halcon routine autobahn
RichView TRVStyle ListStyle 列表样式(项目符号编号)
Go 1.16.4: manage third-party libraries with Mod
Using registered classes to realize specific type matching function template
Complete DNN deep neural network CNN training with tensorflow to complete image recognition cases
金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
Go language web development series 28: solve cross domain access of CORS with gin contrib / CORS
Rasp implementation of PHP
Implementation of Muduo asynchronous logging
MySQL data processing value addition, deletion and modification
Common network state detection and analysis tools
IBEM 数学公式检测数据集