QT_系列_002[动态扩展对话框]

#ifndef DYNAMICDIALOG_H
#define DYNAMICDIALOG_H

#include <QtGui/QDialog>
#include "ui_dynamicdialog.h"

class DynamicDialog : public QDialog, public Ui::DynamicDialogClass
{
    Q_OBJECT

public:
    DynamicDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
    ~DynamicDialog();

    //TODO
    void setColumnRange(QChar first, QChar last);
};

#endif // DYNAMICDIALOG_H

 

------------------------------华丽分割线--------------------------------

 

#include "dynamicdialog.h"

DynamicDialog::DynamicDialog(QWidget *parent, Qt::WFlags flags)
    : QDialog(parent, flags)
{
    setupUi(this);
    //TODO
    //--隐藏两个groupbox
    secondaryGroupBox-&gt;hide();
    tertiaryGroupBox-&gt;hide();
    //不可改变窗口大小
    layout()-&gt;setSizeConstraint(QLayout::SetFixedSize);

    setColumnRange('A', 'Z');
}

DynamicDialog::~DynamicDialog()
{

}

void DynamicDialog::setColumnRange(QChar first, QChar last)
{
    primaryColumnComboBox-&gt;clear();
    secondaryColumnComboBox-&gt;clear();
    tertiaryColumnComboBox-&gt;clear();

    secondaryColumnComboBox-&gt;addItem(tr("None"));
    tertiaryColumnComboBox-&gt;addItem(tr("None"));
    primaryColumnComboBox-&gt;setMinimumSize(secondaryColumnComboBox-&gt;sizeHint());

    QChar ch = first;
    while(ch <= last){
        primaryColumnComboBox->addItem(QString(ch));
        secondaryColumnComboBox-&gt;addItem(QString(ch));
        tertiaryColumnComboBox-&gt;addItem(QString(ch));
        ch = ch.unicode() + 1;
    }
}

你可能感兴趣的:(职场,动态,对话框,休闲)