当前位置:网站首页>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

边栏推荐
- Uniapp skills - dom display and hiding
- Unity embeddedbrowser browser plug-in event communication
- JVM family - overview, program counter day1-1
- Multi person collaborative data annotation based on Baidu brain easydata from scratch
- FPGA测试方法以Mentor工具为例
- [technology development-24]: characteristics of existing IOT communication technology
- 记录关于银行回调post请求405 问题
- GoLand 2021.1.1: configure the multi line display of the tab of the open file
- Spring cup eight school league
- 又一个行业被中国芯片打破空白,难怪美国模拟芯片龙头降价抛售了
猜你喜欢

Go language unit test 5: go language uses go sqlmock and Gorm to do database query mock

Summary of common error reporting problems and positioning methods of thrift

There is nothing new under the sun. Can the meta universe go higher?

NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon

Multi person collaborative data annotation based on Baidu brain easydata from scratch

GoLand 2021.1.1: configure the multi line display of the tab of the open file

RichView TRVStyle ListStyle 列表样式(项目符号编号)

如何使用lxml判断网站公告是否更新

Use docker to build sqli lab environment and upload labs environment, and the operation steps are provided with screenshots.

PhpMyAdmin stage file contains analysis traceability
随机推荐
JVM family - overview, program counter day1-1
Go language web development series 29: Gin framework uses gin contrib / sessions library to manage sessions (based on cookies)
Windos creates Cordova prompt because running scripts is prohibited on this system
Disruptor -- a high concurrency and high performance queue framework for processing tens of millions of levels
挡不住了,国产芯片再度突进,部分环节已进到4nm
RocksDB LRUCache
Qt学习20 Qt 中的标准对话框(中)
jvm-运行时数据区
怎样删除对象的某个属性或⽅法
pytorch 载入历史模型时更换gpu卡号,map_location设置
Use vscode to view hex or UTF-8 codes
Mysql:insert date:SQL 错误 [1292] [22001]: Data truncation: Incorrect date value:
GoLand 2021.1.1: configure the multi line display of the tab of the open file
交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳
Use docker to build sqli lab environment and upload labs environment, and the operation steps are provided with screenshots.
GoLand 2021.1: rename the go project
Uniapp skills - scrolling components -1
HALCON联合C#检测表面缺陷——HALCON例程autobahn
page owner特性浅析
双向链表(我们只需要关注插入和删除函数)