这几次主要练习 Qt Designer
的设计,所以就做了对话框,没有去做具体的实现,以后有空再写吧….哇哈哈
主要代码如下:
sortdialog.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| #ifndef SORTDAILOG_H #define SORTDAILOG_H #include <QtGui/QDialog> #include "ui_sortdailog.h" namespace Ui { class sortdailogClass; } class sortdailog : public QDialog { Q_OBJECT public: sortdailog(QWidget *parent = 0); ~sortdailog(); void setColumnRange(QChar first,QChar last); private: Ui::sortdailogClass *ui; }; #endif
|
sortdialog.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| #include "sortdailog.h" #include<QtGui>
sortdailog::sortdailog(QWidget *parent) : QDialog(parent) { ui->setupUi(this); ui->secondaryGroupBox->hide(); ui->tertiaryGroupBox->hide(); this->layout()->setSizeConstraint(QLayout::SetFixedSize); setColumnRange('A','Z'); } sortdailog::~sortdailog() { delete ui; } void sortdailog::setColumnRange(QChar first,QChar last) { ui->primaryComboBox->clear(); ui->secondaryComboBox->clear(); ui->tertiaryComboBox->clear(); ui->secondaryComboBox->addItem(tr("None")); ui->tertiaryComboBox->addItem(tr("None")); ui->primaryComboBox->setMinimumSize(ui->secondaryComboBox->sizeHint()); QChar ch=first; while(ch<=last) { ui->primaryComboBox->addItem(QString(ch)); ui->secondaryComboBox->addItem(QString(ch)); ui->tertiaryComboBox->addItem(QString(ch)); ch=ch.unicode()+1; } }
|
main.cpp
1 2 3 4 5 6 7 8 9 10
| #include <QtGui/QApplication> #include "sortdailog.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); sortdailog *dialog=new sortdailog; dialog->setColumnRange('C','H'); dialog->show(); return a.exec(); }
|