查看完整版本: [-- 请教关于QDialogButtonBox与QPushButton的问题 --]

QTCN开发网 -> Qt基础编程 -> 请教关于QDialogButtonBox与QPushButton的问题 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

eosin 2011-07-12 10:23

请教关于QDialogButtonBox与QPushButton的问题

参照qt4 gui书上的例子,gotocell工程中,使用QtCreator工具创建的界面gotocelldialog.ui,QDialogButtonBox创建的按钮盒名称是buttonBox,在对话框构造函数中,使用buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);禁用OK按钮,编译报错信息说QPushButton前向声明不完整,并且“->setEnabled(false)”这部分用ctrl+空格不能自动补全,如果用QPushButton创建ok和cancel按钮则编译正常,请战友帮忙解答。

XChinux 2011-07-12 13:59
post your code and the build error message to here

eosin 2011-07-15 19:26
经过多次试验发现了使用QDialogButtonBox必须包含QtGui头文件才能成功编译运行,但不知为什么?

dugucloud 2011-07-15 19:37
晕。直接include那个类的名字就可以了。比如说
#include <QDialogButtonBox>

eosin 2011-07-25 17:02
要#include <QtGui/QDialogButtonBox>才行,这样直接包含是不行的,谢谢了

levichenhh 2021-09-04 21:23
我也是这个问题,版本Qt6.0,解决方法,在开头调用#include <QPushButton>


查看完整版本: [-- 请教关于QDialogButtonBox与QPushButton的问题 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled