|
1Qter豆
sortdialog.cpp- #include "sortdialog.h"
- #include <QWidget>
- SortDialog::SortDialog(QWidget *parent)
- :QDialog(parent)
- {
- setupUi(this);
- secondaryGroupBox->hide();
- tertiaryGroupBox->hide();
- layout()->setSizeConstraint(QLayout::SetFixedSize);
- setColumnRange('A','Z');
- }
- void SortDialog::setColumnRange(QChar first, QChar last)
- {
- comboBox->clear();
- comboBox_3->clear();
- comboBox_5->clear();
- comboBox_3->addItem(tr("None"));
- comboBox_5->addItem(tr("None"));
- comboBox->setMinimumSize(comboBox_3->sizeHint());
- QChar ch = first;
- while(ch <= last)
- {
- comboBox->addItem(QString(ch));
- comboBox_3->addItem(QString(ch));
- comboBox_5->addItem(QString(ch));
- ch = ch.unicode() + 1;
- }
- }
复制代码 sortdialog.h- #ifndef SORTDIALOG_H
- #define SORTDIALOG_H
- #include <QDialog>
- #include "ui_sortdialog.h"
- class SortDialog: public QDialog,public Ui::SortDialog
- {
- Q_OBJECT
- public:
- SortDialog(QWidget * parent = 0);
- void setColumnRange(QChar first,QChar last);
- };
- #endif // SORTDIALOG_H
复制代码 main.cpp
- #include "sortdialog.h"
- #include <QApplication>
- int main(int argc, char *argv[])
- {
- QApplication a(argc, argv);
- SortDialog *sortdialog = new SortDialog;
- sortdialog->setColumnRange('C','F');
- sortdialog->show();
- return a.exec();
- }
复制代码 出现的问题是:
In constructor 'SortDialog::SortDialog(QWidget*)':
error: no matching function for call to 'SortDialog::setupUi(SortDialog*)'
setupUi(this);
^
candidate: void Ui_SortDialog::setupUi(QMainWindow*)
void setupUi(QMainWindow *SortDialog)
^
no known conversion for argument 1 from 'SortDialog*' to 'QMainWindow*'
c++ qt4书上的例子 2.4
请问怎么解决这个问题
|
最佳答案
查看完整内容
sortdialog.ui 文件 建错了
建立的时候要选 对应的模板, 你这里应该选 qdialog模板
|