当前位置:网站首页>Qt--- create dialog box 3: implementation of shape variable dialog box
Qt--- create dialog box 3: implementation of shape variable dialog box
2022-06-10 06:30:00 【CoderIsArt】
occasionally , Different content needs to be displayed to different users , That is, advanced users have advanced model selection display .
such as , Implement the following extended dialog box

1. use QT desinger Create a dialog box and add elements , Here's the picture

Be careful moreButton, Of checkable Property check , as follows ,

2. Establish signal slot mechanism , as follows ,
1) add to OK, Cancel The signal slot
2) Similar additions moreButton With the display of two combo boxes

Last , The display signal slot is set as follows ,

3. main.cpp
#include "sortdialog.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
SortDialog *sortDlg = new SortDialog;
sortDlg->setColumnRange('C','F');sortDlg->show();
return a.exec();
}
4. sortdialog.h
#ifndef SORTDIALOG_H
#define SORTDIALOG_H
#include <QDialog>
namespace Ui {
class SortDialog;
}
class SortDialog : public QDialog
{
Q_OBJECT
public:
explicit SortDialog(QWidget *parent = nullptr);
~SortDialog();
void setColumnRange(QChar first, QChar last);
private:
Ui::SortDialog *ui;
};
#endif // SORTDIALOG_H
5. sortdialog.cpp
#include "sortdialog.h"
#include "ui_sortdialog.h"
SortDialog::SortDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SortDialog)
{
ui->setupUi(this);
ui->secondaryGroupBox->hide();
ui->tertiaryGroupBox->hide();
layout()->setSizeConstraint(QLayout::SetFixedSize);
setColumnRange('A', 'Z');}
SortDialog::~SortDialog()
{
delete ui;
}
void SortDialog::setColumnRange(QChar first, QChar last)
{
ui->primaryColumnCombo->clear();
ui->secondaryColumnCombo->clear();
ui->tertiaryColumnCombo->clear();
ui->secondaryColumnCombo->addItem(tr("None")); ui->tertiaryColumnCombo->addItem(tr("None"));ui->primaryColumnCombo->setMinimumSize(
ui->secondaryColumnCombo->sizeHint());
QChar ch = first;
while(ch <= last) {
ui->primaryColumnCombo->addItem(QString(ch));
ui->secondaryColumnCombo->addItem(QString(ch));
ui->tertiaryColumnCombo->addItem(QString(ch));
ch = ch.unicode() + 1;
}
}
边栏推荐
- What does end system mean?
- BOM browser object model
- SQL practice part: SQL row column conversion and real problems
- QT---创建对话框3:形状可变对话框的实现
- WireShark抓包分析
- Analyse de la capture de paquets wireshark
- 电脑新加内存条后 游戏崩溃 浏览器卡死 电脑蓝屏
- QT upper computer controls ABB in real time through EGM
- ECMAScript 6 syntax addition (shorthand)
- Unity fully elastic collision
猜你喜欢

Stm32f1 and stm32subeide quick start - overview of interrupts, NVIC and exti

Xshell下载安装使用简单教程

Oriental Star Hotel Management Catering project - query function

SQL practice: SQL foundation and execution sequence

基于对应点关系的——两片点云剔除(保留)重复点

ArcGIS application (XVIII) detailed explanation of display accuracy change of ArcGIS vector layer attribute table

OSPF route summary experiment

Analyse de la capture de paquets wireshark

Deploy MySQL based on statefulset in kubernetes (Part 2)

李宏毅老师《机器学习》课程笔记-4.2 Batch Normalization
随机推荐
BOM browser object model
618. How to prepare for the great promotion
excel中如何把文本转换成数值?
Method of canceling automatic numbering
PM2 installation and common commands
基于对应点关系的——两片点云剔除(保留)重复点
Print linked list from end to end of sword finger offer
Thank you for the Big White Rabbit candy of Yuyi children's shoes
RedisTemplate存取删除数据之ZSet
Virtual machine network connection mode
SQL practice: SQL solves problems in recent X days
Analyse de la capture de paquets wireshark
深度解析智能运维下告警关联频繁项集挖掘算法原理
将json文件里面的数据写入数据库
How to extract some specific text in excel?
Opengauss database ODBC environment connection configuration (Windows)
Jerry's aicmd command [chapter]
Packing and unpacking in C #
反向域名解析是什么?
Business topic: ab test experiment design and evaluation