我在工程中新见一个继承自QDialog的类,为什么必须创建ui文件?我不想用designer建立
界面但是我在手写代码后
编译可以通过,界面却
显示不出来了,这是什么原因?
我把写的代码去掉后就又可以显示了。
然后我新建了一个纯
C++类,让它集成QDialog,调用resize却会报错?
本人小白
新手,大侠多多指教
- #include "tfinddialog.h"
- #include "ui_tfinddialog.h"
- #include <QLabel>
- #include <QLineEdit>
- #include <QCheckBox>
- #include <QHBoxLayout>
- #include <QVBoxLayout>
- #include <QPushButton>
- TFindDialog::TFindDialog(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::TFindDialog)
- { ui->setupUi(this);
- //----------------------------
- // UI初始化
- //---------------------------
- label = new QLabel(tr("Find &What?"));
- lineEdit = new QLineEdit();
- label->setBuddy(lineEdit);
- caseCheckBox = new QCheckBox(tr("Match &case"));
- backwardCheckBox = new QCheckBox(tr("Search &backward"));
- findButton = new QPushButton(tr("&Find"));
- findButton->setDefault(true);
- findButton->setEnabled(false);
- closeButton = new QPushButton(tr("&Cacel"));
- QHBoxLayout *topLeftLayout = new QHBoxLayout;
- topLeftLayout->addWidget(label);
- topLeftLayout->addWidget(lineEdit);
- QHBoxLayout *bottomLeftLayout = new QHBoxLayout;
- bottomLeftLayout->addWidget(caseCheckBox);
- bottomLeftLayout->addWidget(backwardCheckBox);
- QVBoxLayout *rightLayout = new QVBoxLayout;
- rightLayout->addWidget(findButton);
- rightLayout->addWidget(closeButton);
- QVBoxLayout *leftLayout = new QVBoxLayout;
- leftLayout->addLayout(topLeftLayout);
- leftLayout->addLayout(bottomLeftLayout);
- QHBoxLayout *mainLayout = new QHBoxLayout;
- mainLayout->addLayout(leftLayout);
- mainLayout->addLayout(rightLayout);
- setLayout(mainLayout);
- resize(200,200);
- }
[ 此帖被ctogo在2011-02-24 13:03重新编辑 ]