首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

请教QT中CPP文件里如何引用UI文件里创建的东西啊

2012-06-18 
请问QT中CPP文件里怎么引用UI文件里创建的东西啊?我在UI文件里创建了一个按钮。比如类名叫 OKButton然后在C

请问QT中CPP文件里怎么引用UI文件里创建的东西啊?
我在UI文件里创建了一个按钮。比如类名叫 OKButton
然后在CPP文件里用 OKButton 说在此区域没有定义。
请问怎么解决啊?

[解决办法]

QUiLoader loader;
QFile file(":/forms/myform.ui");
file.open(QFile::ReadOnly);
QWidget *myWidget = loader.load(&file, this);
file.close();

QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(myWidget);
setLayout(layout);
this is QT ASsistant,input "QUILoader"

热点排行