当前位置:网站首页>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
- [acnoi2022] guess numbers
- 金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
- 双向链表(我们只需要关注插入和删除函数)
- Flutter dynamic | fair 2.5.0 new version features
- MySQL 数据增删改查综合案例
- The solution of Chinese font garbled code in keil5
- Golang — 命令行工具cobra
- Function calling convention
- JS continues to explore...
猜你喜欢
Unity embeddedbrowser browser plug-in event communication
[email protected]纳米粒子"/>
金属有机骨架MIL-88负载阿霉素DOX|叶酸修饰UiO-66-NH2负载阿霉素[email protected]纳米粒子
MySQL 数据处理值增删改
28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
Go language web development series 30: gin: grouping by version for routing
解决MySql 1045 Access denied for user ‘root‘@‘localhost‘ (using password: YES)
jvm-对象生命周期
Go language web development series 27: Gin framework: using gin swagger to implement interface documents
Rasp implementation of PHP
Spring cup eight school league
随机推荐
Go language unit test 5: go language uses go sqlmock and Gorm to do database query mock
Mysql:insert date:sql error [1292] [22001]: data truncation: incorrect date value:
Leetcode-1175.Prime Arrangements
Qt学习18 登录对话框实例分析
Another industry has been broken by Chinese chips. No wonder the leading analog chip companies in the United States have cut prices and sold off
Uniapp skills - dom display and hiding
金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
项目协作的进度如何推进| 社区征文
SQL Injection (AJAX/JSON/jQuery)
Go language web development series 30: gin: grouping by version for routing
PhpMyAdmin stage file contains analysis traceability
如何使用lxml判断网站公告是否更新
Mastering the cypress command line options is the basis for truly mastering cypress
C language standard IO function sorting
使用vscode查看Hex或UTF-8编码
RocksDB LRUCache
Field problems in MySQL
pytorch 载入历史模型时更换gpu卡号,map_location设置
[quantitative trading] permanent portfolio, turtle trading rules reading, back testing and discussion
Implementation of Muduo accept connection, disconnection and sending data