QT: sort dialog
来源:互联网 发布:学生空间七天网络下载 编辑:程序博客网 时间:2024/06/12 22:51
new a dialog, add some buttons, button is an object which has a name and has a text.
select some buttons, then form/lay out ver or h
new a groupbox, add some objects, then form/lay out grid
Edit/edit widget. signal slot. tab order
1. Click File|New Form and choose the "Dialog without Buttons" template.
2. Create an OK button and drag it to the top right of the form. Change its objectName to "okButton" and set its default property to "true".
3Create a Cancel button, and drag it below the OK button. Change its objectName to "cancelButton".
4. Create a vertical spacer and drag it below the Cancel button, then create a More button and drag it below the vertical spacer. Change the More button's objectName to "moreButton", set its text property to "&More", and its checkable property to "true".
5. Click the OK button, then Shift+Click the Cancel button, the vertical spacer, and the More button, then click Form|Lay Out Vertically.生成右边的lay out
6. Create a group box, two labels, two comboboxes, and one horizontal spacer, and put them
anywhere on the form.
7. Right-click the first combobox and choose Edit Items from the context menu to pop up Qt
Designer's combobox editor. Create one item with the text "None".
8. Right-click the second combobox and choose Edit Items. Create an "Ascending" item and a
"Descending" item.
9.Hold down the Ctrl key (Alt on the Mac) and click and drag the Primary Key group box to create a
copy of the group box (and its contents) on top of the original.
10.Click Edit|Edit Signals/Slots to enter Qt Designer's connection mode,To establish a connection between two widgets, click the sender widget "OK Button" and drag the red arrow line to the receiver widget"group box 2", then release. select toggeled signal and slot setvisible
11.connect the okButton and the form's accept() slot.Drag the red arrow line from the okButton to an empty part of the form, then release.
Save the dialog as sortdialog.ui
create a sortdialog.h
#ifndef SORTDIALOG_H
#define SORTDIALOG_H
#include <QDialog>
#include "ui_sortdialog.h"
class SortDialog : public QDialog, public Ui::SortDialog
{
Q_OBJECT
public:
SortDialog(QWidget *parent = 0);
void setColumnRange(QChar first, QChar last);
};
#endif
create sortdialog.cpp:
1 #include <QtGui>
2 #include "sortdialog.h"
3 SortDialog::SortDialog(QWidget *parent)
4 : QDialog(parent)
5 {
6 setupUi(this);
7 secondaryGroupBox->hide();
8 tertiaryGroupBox->hide();//hides the secondary and tertiary parts of the dialog.
9 layout()->setSizeConstraint(QLayout::SetFixedSize);//making the dialog non-resizable by the user.
10 setColumnRange('A', 'Z');
11 }
12 void SortDialog::setColumnRange(QChar first, QChar last)
13 {
14 primaryColumnCombo->clear();
15 secondaryColumnCombo->clear();
16 tertiaryColumnCombo->clear();
17 secondaryColumnCombo->addItem(tr("None"));
18 tertiaryColumnCombo->addItem(tr("None"));
19 primaryColumnCombo->setMinimumSize(
20 secondaryColumnCombo->sizeHint());//sizeHint() function returns a widget's"ideal" size
21 QChar ch = first;
22 while (ch <= last) {
23 primaryColumnCombo->addItem(QString(ch));
24 secondaryColumnCombo->addItem(QString(ch));
25 tertiaryColumnCombo->addItem(QString(ch));
26 ch = ch.unicode() + 1;
27 }
28 }
#include <QApplication>
#include "sortdialog.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
SortDialog *dialog = new SortDialog;
dialog->setColumnRange('C', 'F');
dialog->show();
return app.exec();
}
- QT: sort dialog
- qt-dialog
- Qt Dialog
- QT widgets dialog
- Qt学习之Dialog
- QT dialog一种使用方法
- Qt dialog 对话框
- QT dialog 模态
- QT之对话框Dialog
- 在Qt的dialog中内嵌一个dialog
- QT 创建对话框 Dialog 实例
- QT(5)Dialog - Addressbook例子3
- QT中Dialog显示最大化最小化按钮
- QT Dialog 显示最大化最小化按钮
- Qt Tab Dialog Example 看看看~
- QT软件中加入新dialog
- qt之一个登陆dialog界面
- QT中Dialog显示最大化最小化按钮
- 谈点Android系统的趋势
- WinForm 控件 简单设置快捷键
- Linux 静态库与动态库搜索路径设置
- linux输入子系统(3)
- 豪盛手台操作方法
- QT: sort dialog
- Best practices for modern Javascript development
- linux输入子系统(4)
- 百度空间不适合开发BLOG,所以准备转战CSDN,专业!
- 常用数据库 取前几条数据 sql写法
- VS与Win7共舞:系统服务的Session 0隔离
- servlet的session管理
- 软件工程师发展之路之我见(一)
- TOP 字句的运用