对不起,如果这是一个愚蠢的问题。我不是偷懒。我正在使用 Qt 4 进行 C++ GUI 编程,书中的一个示例与 Qt 对我的工作方式不同。
它让我进行对话,然后连接一些信号和插槽。好吧,那行不通,所以我尝试了一些现实检查。我什至无法手动编辑对象属性。
这里主要
#include <QApplication>
#include <QDialog>
#include <iostream>
#include "ui_gotocelldialog.h"
using namespace std;
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Ui::GoToCellDialog ui;
QDialog *d = new QDialog;
ui.setupUi(d);
d->show();
return app.exec();
}
这是我的对话框 .cpp 文件
#include "gotocelldialog.h"
#include "ui_gotocelldialog.h"
#include <iostream>
using namespace std;
GoToCellDialog::GoToCellDialog(QWidget *parent) :
QWidget(parent),
ui(new Ui::GoToCellDialog)
{
cout << "!!!!!!!!!!!!!!!!!!!!!"; // i never see this
ui->setupUi(this); // but if i comment out this it doesnt init
ui->okButton->setEnabled(true); // this does nothing
}
GoToCellDialog::~GoToCellDialog()
{
delete ui;
}
这是设计模式下的 GoToCellDialog 表单
我只是想启用默认禁用的 okButton。另外,如果我 cout << "abc"; 它没有出现。你能解释一下吗?