当前位置:网站首页>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
边栏推荐
- Go language web development series 29: Gin framework uses gin contrib / sessions library to manage sessions (based on cookies)
- How to use lxml to judge whether the website announcement is updated
- Use docker to build sqli lab environment and upload labs environment, and the operation steps are provided with screenshots.
- logback日志的整理
- Qt学习18 登录对话框实例分析
- 顺序表(C语言实现)
- “又土又穷”的草根高校,凭什么被称为“东北小清华”?
- NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
- Qt学习22 布局管理器(一)
- jvm-运行时数据区
猜你喜欢

SQL Injection (POST/Search)

Error running 'application' in idea running: the solution of command line is too long
[email protected]纳米粒子"/>金属有机骨架MIL-88负载阿霉素DOX|叶酸修饰UiO-66-NH2负载阿霉素[email protected]纳米粒子

logback日志的整理

28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;

核酸修饰的金属有机框架药物载体|PCN-223金属有机骨架包载Ad金刚烷|ZIF-8包裹阿霉素(DOX)

3D视觉——2.人体姿态估计(Pose Estimation)入门——OpenPose含安装、编译、使用(单帧、实时视频)

SQL Injection (AJAX/JSON/jQuery)

可编程逻辑器件软件测试
[email protected])|制备路线"/>叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线
随机推荐
从零开始的基于百度大脑EasyData的多人协同数据标注
RocksDB LRUCache
MIL-100( Fe) 包裹小分子阿司匹林形成[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)
信创产业现状、分析与预测
Go 1.16.4: purpose of go mod tidy
【吉林大学】考研初试复试资料分享
Windos creates Cordova prompt because running scripts is prohibited on this system
jvm-对象生命周期
MySQL data processing value addition, deletion and modification
PhpMyAdmin stage file contains analysis traceability
Spring cup eight school league
Dynamic programming 01 knapsack and complete knapsack
Qt学习21 Qt 中的标准对话框(下)
3D视觉——2.人体姿态估计(Pose Estimation)入门——OpenPose含安装、编译、使用(单帧、实时视频)
Static linked list (subscript of array instead of pointer)
MySQL 数据增删改查综合案例
28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
Replace the GPU card number when pytorch loads the historical model, map_ Location settings
[bw16 application] instructions for firmware burning of Anxin Ke bw16 module and development board update
The solution of Chinese font garbled code in keil5