当前位置:网站首页>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
边栏推荐
- IBEM 数学公式检测数据集
- Uniapp tips - set background music
- 金属有机骨架MOFs装载非甾体类抗炎药物|ZIF-8包裹普鲁士蓝负载槲皮素(制备方法)
- 金属有机骨架MIL-88负载阿霉素DOX|叶酸修饰UiO-66-NH2负载阿霉素[email protected]纳米粒子
- Screenshot of the operation steps of upload labs level 4-level 9
- Shell timing script, starting from 0, CSV format data is regularly imported into PostgreSQL database shell script example
- 叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线
- Multi person collaborative data annotation based on Baidu brain easydata from scratch
- How to promote the progress of project collaboration | community essay solicitation
- Implementation of Muduo accept connection, disconnection and sending data
猜你喜欢

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

Go language web development series 28: solve cross domain access of CORS with gin contrib / CORS

Use vscode to view hex or UTF-8 codes

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,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。

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

Mastering the cypress command line options is the basis for truly mastering cypress
[email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂"/>金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
![[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

Uniapp tips - scrolling components
随机推荐
软件测试工作那么难找,只有外包offer,我该去么?
Common network state detection and analysis tools
消息订阅与发布
静态链表(数组的下标代替指针)
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
Summary of common error reporting problems and positioning methods of thrift
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
The latest BSC can pay dividends. Any B usdt Shib eth dividend destruction marketing can
Conversion function and explicit
Uniapp skills - scrolling components -1
金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
GoLand 2021.1.1: configure the multi line display of the tab of the open file
Leetcode-1175.Prime Arrangements
jvm-对象生命周期
Comprehensive case of MySQL data addition, deletion, modification and query
Unity embeddedbrowser browser plug-in event communication
如何使用lxml判断网站公告是否更新
[bw16 application] instructions for firmware burning of Anxin Ke bw16 module and development board update
PhpMyAdmin stage file contains analysis traceability
MySQL 数据处理值增删改