当前位置:网站首页>QT learning 20 standard dialog box in QT (middle)
QT learning 20 standard dialog box in QT (middle)
2022-07-03 13:58:00 【A little black sauce】
Qt Study 20 Qt Standard dialog boxes in ( in )
Color dialog
- Qt Provided in predefined Color dialog QColorDialog class
- QColorDialog Class is used to provide Dialog box for specifying colors

- How to use the color dialog
// Construct color dialog objects
QColorDialog dlg(this);
// Set the relevant properties of the color dialog
dlg.setWindowTitle("Color Editor");
dlg.setCurrentColor(Qt::red); // Initial color
if (dlg.exec() == QColorDialog::Accepted) {
qDebug() << dlg.selectedColor();
}
- Qt Medium QColor Class is used to represent the concept of color in programs
- QColor Class also supports Multiple color representations
- RGB: In red , green , Three color model based on blue
- HSV: In tone , saturation , Based on lightness Hexagonal cone model
- CMYK: With sky blue , magenta , yellow , Black based Full color printing color model
Input Dialog
- Qt Provided in predefined Input dialog box QInputDialog class
- QInputDialog Class used Occasions requiring temporary data input

- How to use the input dialog
// Construct the input dialog
QInputDialog dlg(this);
// Set the relevant properties of the input dialog
dlg.setWindowTitle("Input ...");
dlg.setLabelText("Please enter a integer: ");
dlg.setInputMode(QInputDialog::IntInput);
if (dlg.exec() == QInputDialog::Accepted)
{
qDebug() << dlg.intValue();
}
- Enter the... Of the dialog box The input mode
- QInputDialog::TextInput Enter a text string
- QInputDialog::IntInput Input integer number
- QInputDialog::DoubleInput Enter floating point number
Code experiments
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QPushButton>
class Widget : public QWidget
{
Q_OBJECT
private:
QPushButton ColorDialogBtn;
QPushButton InputDialogBtn;
private slots:
void ColorDialogBtn_Clicked();
void InputDialogBtn_Clicked();
public:
Widget(QWidget *parent = 0);
~Widget();
};
#endif // WIDGET_H
#include "Widget.h"
#include <QDebug>
#include <QColorDialog>
#include <QInputDialog>
Widget::Widget(QWidget *parent)
: QWidget(parent), ColorDialogBtn(this), InputDialogBtn(this)
{
ColorDialogBtn.setText("Color Dialog");
ColorDialogBtn.move(20, 20);
ColorDialogBtn.resize(160, 30);
InputDialogBtn.setText("Input Dialog");
InputDialogBtn.move(20, 70);
InputDialogBtn.resize(160, 30);
resize(200, 120);
setFixedSize(200, 120);
connect(&ColorDialogBtn, SIGNAL(clicked()), this, SLOT(ColorDialogBtn_Clicked()));
connect(&InputDialogBtn, SIGNAL(clicked()), this, SLOT(InputDialogBtn_Clicked()));
}
Widget::~Widget()
{
}
void Widget::ColorDialogBtn_Clicked()
{
QColorDialog dlg(this);
dlg.setWindowTitle("Color Editor");
dlg.setCurrentColor(Qt::red);
if (dlg.exec() == QColorDialog::Accepted) {
QColor color = dlg.selectedColor();
qDebug() << color;
qDebug() << color.red();
qDebug() << color.green();
qDebug() << color.blue();
qDebug() << color.hue();
qDebug() << color.saturation();
qDebug() << color.value();
}
// Simple usage
QColor c = QColorDialog::getColor(Qt::red, this, "Color Edit");
qDebug() << c;
}
void Widget::InputDialogBtn_Clicked()
{
QInputDialog dlg(this);
dlg.setWindowTitle("Input Test");
dlg.setLabelText("Please input a string:");
dlg.setInputMode(QInputDialog::TextInput);
if (dlg.exec() == QInputDialog::Accepted) {
qDebug() << dlg.textValue();
}
// Simple usage
qDebug() << QInputDialog::getDouble(this, "Input double", "Please input double:");
qDebug() << QInputDialog::getInt(this, "Input int", "Please input int:");
QStringList ql;
QStringList items;
items << tr("Spring") << tr("Summer") << tr("Fall") << tr("Winter");
bool ok;
QString item = QInputDialog::getItem(this, tr("QInputDialog::getItem()"),
tr("Season:"), items, 0, false, &ok);
qDebug() << item;
QString str = QInputDialog::getText(this, "getText", "Please input text:");
qDebug() << str;
}
#include "Widget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}
Summary
- QColorDialog Class is used to provide Dialog box parts with assigned colors
- QColor Class is used in programs to represent Color The concept of
- QInputDialog Class used Occasions requiring temporary data input
边栏推荐
- 信创产业现状、分析与预测
- Replace the GPU card number when pytorch loads the historical model, map_ Location settings
- PhpMyAdmin stage file contains analysis traceability
- 【556. 下一个更大元素 III】
- IBEM mathematical formula detection data set
- 金属有机骨架MOFs装载非甾体类抗炎药物|ZIF-8包裹普鲁士蓝负载槲皮素(制备方法)
- Golang — template
- 全局事件总线
- RichView TRVStyle ListStyle 列表样式(项目符号编号)
- Go: send the get request and parse the return JSON (go1.16.4)
猜你喜欢

MySQL 数据增删改查综合案例

可编程逻辑器件软件测试

“又土又穷”的草根高校,凭什么被称为“东北小清华”?

又一个行业被中国芯片打破空白,难怪美国模拟芯片龙头降价抛售了
![[quantitative trading] permanent portfolio, turtle trading rules reading, back testing and discussion](/img/3b/28327bbf5eb19254f03500a41e2adb.jpg)
[quantitative trading] permanent portfolio, turtle trading rules reading, back testing and discussion

Go language unit test 3: go language uses gocovey library to do unit test

Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station

核酸修饰的金属有机框架药物载体|PCN-223金属有机骨架包载Ad金刚烷|ZIF-8包裹阿霉素(DOX)
![Mysql:insert date:sql error [1292] [22001]: data truncation: incorrect date value:](/img/2f/33504391a661ecb63d42d75acf3a37.png)
Mysql:insert date:sql error [1292] [22001]: data truncation: incorrect date value:

交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳
随机推荐
28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
Qt学习24 布局管理器(三)
项目协作的进度如何推进| 社区征文
Windos creates Cordova prompt because running scripts is prohibited on this system
树的深入和广度优先遍历(不考虑二叉树)
Unable to stop it, domestic chips have made another breakthrough, and some links have reached 4nm
Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)
Go language web development series 27: Gin framework: using gin swagger to implement interface documents
掌握Cypress命令行选项,是真正掌握Cypress的基础
Go language web development series 28: solve cross domain access of CORS with gin contrib / CORS
Shell timing script, starting from 0, CSV format data is regularly imported into PostgreSQL database shell script example
C language standard IO function sorting
叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线
Comprehensive case of MySQL data addition, deletion, modification and query
jvm-对象生命周期
[technology development-24]: characteristics of existing IOT communication technology
Error running 'application' in idea running: the solution of command line is too long
[understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered
Flutter dynamic | fair 2.5.0 new version features
jvm-类加载