当前位置:网站首页>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
边栏推荐
- Qt学习25 布局管理器(四)
- 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
- 如何使用lxml判断网站公告是否更新
- 小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。
- 全面发展数字经济主航道 和数集团积极推动UTONMOS数藏市场
- Depth and breadth first traversal of tree (regardless of binary tree)
- Qt学习18 登录对话框实例分析
- Unity embeddedbrowser browser plug-in event communication
- Mobile phones and computers can be used, whole people, spoof code connections, "won't you Baidu for a while" teach you to use Baidu
猜你喜欢

SQL Injection (AJAX/JSON/jQuery)

RocksDB LRUCache

Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)

Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue

HALCON联合C#检测表面缺陷——HALCON例程autobahn

Go language web development series 29: Gin framework uses gin contrib / sessions library to manage sessions (based on cookies)
![[bw16 application] instructions for firmware burning of Anxin Ke bw16 module and development board update](/img/b8/31609303fd817c48b6fff7c43f31e5.png)
[bw16 application] instructions for firmware burning of Anxin Ke bw16 module and development board update

PhpMyAdmin stage file contains analysis traceability
![[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

Logback log sorting
随机推荐
GoLand 2021.2 configure go (go1.17.6)
Qt学习18 登录对话框实例分析
Complete DNN deep neural network CNN training with tensorflow to complete image recognition cases
Use vscode to view hex or UTF-8 codes
Flutter dynamic | fair 2.5.0 new version features
SQL Injection (GET/Select)
There is nothing new under the sun. Can the meta universe go higher?
Use and design of Muduo buffer class
Rasp implementation of PHP
How to use lxml to judge whether the website announcement is updated
Multi person collaborative data annotation based on Baidu brain easydata from scratch
RocksDB LRUCache
Uniapp skills - dom display and hiding
[机缘参悟-37]:人感官系统的结构决定了人类是以自我为中心
[combinatorics] permutation and combination (two counting principles, examples of set permutation | examples of set permutation and circle permutation)
windos 创建cordova 提示 因为在此系统上禁止运行脚本
Students who do not understand the code can also send their own token, which is easy to learn BSC
Qt学习24 布局管理器(三)
Screenshot of the operation steps of upload labs level 4-level 9
Use docker to build sqli lab environment and upload labs environment, and the operation steps are provided with screenshots.