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

边栏推荐
- Mobile phones and computers can be used, whole people, spoof code connections, "won't you Baidu for a while" teach you to use Baidu
- 小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。
- [combinatorics] permutation and combination (two counting principles, examples of set permutation | examples of set permutation and circle permutation)
- windos 创建cordova 提示 因为在此系统上禁止运行脚本
- Go 1.16.4: manage third-party libraries with Mod
- [acnoi2022] guess numbers
- SQL Injection (GET/Search)
- Use vscode to view hex or UTF-8 codes
- [combinatorics] permutation and combination (examples of combinatorial number of multiple sets | three counting models | selection problem | combinatorial problem of multiple sets | nonnegative intege
- 静态链表(数组的下标代替指针)
猜你喜欢

Unity embeddedbrowser browser plug-in event communication

The latest BSC can pay dividends. Any B usdt Shib eth dividend destruction marketing can

How to use lxml to judge whether the website announcement is updated

Ocean CMS vulnerability - search php

全面发展数字经济主航道 和数集团积极推动UTONMOS数藏市场

小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。

交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳

Qt学习20 Qt 中的标准对话框(中)

MySQL 数据增删改查综合案例

UiO-66-COOH装载苯达莫司汀|羟基磷灰石( HA) 包裹MIL-53(Fe)纳米粒子|装载黄芩苷锰基金属有机骨架材料
随机推荐
栈应用(平衡符)
Stack application (balancer)
Rasp implementation of PHP
jvm-运行时数据区
金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])
HALCON联合C#检测表面缺陷——HALCON例程autobahn
Leetcode-1175.Prime Arrangements
金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
Which securities company has the lowest Commission for opening an account online? I want to open an account. Is it safe for the online account manager to open an account
JS general form submission 1-onsubmit
jvm-对象生命周期
掌握Cypress命令行选项,是真正掌握Cypress的基础
The solution of Chinese font garbled code in keil5
小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。
交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳
“又土又穷”的草根高校,凭什么被称为“东北小清华”?
太阳底下无新事,元宇宙能否更上层楼?
There is nothing new under the sun. Can the meta universe go higher?
Software testing is so hard to find, only outsourcing offers, should I go?
Unable to stop it, domestic chips have made another breakthrough, and some links have reached 4nm