这几次主要练习 Qt Designer
的设计,所以就做了对话框,没有去做具体的实现,以后有空再写吧….哇哈哈
主要代码如下:
sortdialog.h
#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
#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
#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(); }
|