文件sortdialog.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SortDialog</class>
<widget class="QDialog" name="SortDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>285</width>
<height>314</height>
</rect>
</property>
<property name="windowTitle">
<string>Sort</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="primaryGropBox">
<property name="title">
<string>&Primary Key</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Column:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="primaryColumnCombo">
<item>
<property name="text">
<string>None</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>32</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Order:</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="primaryOrderCombo">
<item>
<property name="text">
<string>Ascending</string>
</property>
</item>
<item>
<property name="text">
<string>Decsending</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="okButton">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="moreButton">
<property name="text">
<string>&More</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="secondaryGroupBox">
<property name="title">
<string>&Secondary Key</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Column:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="secondaryColumnCombo">
<item>
<property name="text">
<string>None</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>32</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Order:</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="secondaryOrderCombo">
<item>
<property name="text">
<string>Ascending</string>
</property>
</item>
<item>
<property name="text">
<string>Decsending</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="tertiaryGroupBox">
<property name="title">
<string>&Tertiary Key</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Column:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="tertiaryColumnCombo">
<item>
<property name="text">
<string>None</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>32</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Order:</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="tertiaryOrderCombo">
<item>
<property name="text">
<string>Ascending</string>
</property>
</item>
<item>
<property name="text">
<string>Decsending</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>okButton</sender>
<signal>clicked()</signal>
<receiver>SortDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>200</x>
<y>31</y>
</hint>
<hint type="destinationlabel">
<x>204</x>
<y>115</y>
</hint>
</hints>
</connection>
<connection>
<sender>cancelButton</sender>
<signal>clicked()</signal>
<receiver>SortDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>209</x>
<y>58</y>
</hint>
<hint type="destinationlabel">
<x>211</x>
<y>142</y>
</hint>
</hints>
</connection>
<connection>
<sender>moreButton</sender>
<signal>toggled(bool)</signal>
<receiver>secondaryGroupBox</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>220</x>
<y>93</y>
</hint>
<hint type="destinationlabel">
<x>183</x>
<y>182</y>
</hint>
</hints>
</connection>
<connection>
<sender>moreButton</sender>
<signal>toggled(bool)</signal>
<receiver>tertiaryGroupBox</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>236</x>
<y>98</y>
</hint>
<hint type="destinationlabel">
<x>149</x>
<y>251</y>
</hint>
</hints>
</connection>
</connections>
</ui>
文件main.cpp
#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();
}
文件sortdialog.cpp
#include <QtGui>
#include "sortdialog.h"
SortDialog::SortDialog(QWidget *parent)
:QDialog(parent)
{
setupUi(this);
secondaryGroupBox->hide();
tertiaryGroupBox->hide();
layout()->setSizeConstraint(QLayout::SetFixedSize);
setColumnRange('A','Z');
}
void SortDialog::setColumnRange(QChar first, QChar last)
{
primaryColumnCombo->clear();
secondaryColumnCombo->clear();
tertiaryColumnCombo->clear();
secondaryColumnCombo->addItem(tr("None"));
tertiaryColumnCombo->addItem(tr("None"));
primaryColumnCombo->setMinimumSize(secondaryColumnCombo->sizeHint());
QChar ch = first;
while(ch <= last)
{
primaryColumnCombo->addItem(QString(ch));
secondaryColumnCombo->addItem(QString(ch));
tertiaryColumnCombo->addItem(QString(ch));
ch = ch.unicode()+1;
}
}
文件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