Qt代码之改变形状的对话框

一、designer之ui

Qt代码之改变形状的对话框_第1张图片

二、头文件之sortdialog.h

#ifndef DIALOG_H
#define DIALOG_H

#include 
#include "ui_sortdialog.h"

class SortDialog : public QDialog, public Ui::SortDialog
{
    Q_OBJECT

public:
    SortDialog(QWidget *parent = nullptr);
    ~SortDialog();

    void setColumeRange(QChar first, QChar last);
};

#endif // DIALOG_H

三、实现文件之sortdialog.cpp

#include "sortdialog.h"
#include 

SortDialog::SortDialog(QWidget *parent)
    : QDialog(parent)
{
    setupUi(this);
    secondaryBox->hide();
    tertiaryBox->hide();

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

void SortDialog::setColumeRange(QChar first, QChar last)
{
    primaryColumeCombo->clear();
    secondaryColumeCombo->clear();
    tertiaryColumeCombo->clear();

    secondaryColumeCombo->addItem("None");
    tertiaryColumeCombo->addItem("None");
    primaryColumeCombo->setMinimumSize(secondaryColumeCombo->sizeHint());

    QChar ch = first;
    while (ch <= last) {
        primaryColumeCombo->addItem(QString(ch));
        secondaryColumeCombo->addItem(QString(ch));
        tertiaryColumeCombo->addItem(QString(ch));
        ch = ch.unicode() + 1;
    }
}

SortDialog::~SortDialog()
{

}

四、main

#include "sortdialog.h"

#include 

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    SortDialog w;
    w.setColumeRange('C', 'F');
    w.show();
    return a.exec();
}

五、运行结果

Qt代码之改变形状的对话框_第2张图片====>Qt代码之改变形状的对话框_第3张图片

你可能感兴趣的:(编码,Qt)