能改变形状的对话框

设计图及效果图:

 

设计花了不少时间,主要成果是了解了一些qt designer的用法。

下面贴代码

changedialog.h

#ifndef CHANGEDIALOG_H #define CHANGEDIALOG_H #include #include "ui_changedialog.h" class changedialog : public QDialog { Q_OBJECT public: changedialog(QWidget *parent = 0, Qt::WFlags flags = 0); ~changedialog(); void setColumnRange(QChar first, QChar last);//就加了这句 private: Ui::changedialogClass ui; }; #endif // CHANGEDIALOG_H  

changedialog.cpp

#include "changedialog.h" changedialog::changedialog(QWidget *parent, Qt::WFlags flags) : QDialog(parent, flags) { ui.setupUi(this); ui.secondaryGroupBox->hide(); ui.tertiaryGroupBox->hide(); layout()->setSizeConstraint(QLayout::SetFixedSize); setColumnRange('A', 'Z'); } void changedialog::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; } } changedialog::~changedialog() { }  

main.cpp

#include "changedialog.h" #include int main(int argc, char *argv[]) { QApplication a(argc, argv); changedialog w; w.setColumnRange('C', 'F'); w.show(); return a.exec(); }  

你可能感兴趣的:(QT,qt,ui,layout,class,c)