netbeans:如何将小部件添加到QT变量 [英] netbeans: how to add widgets to QT variable
问题描述
我见过一些帖子,人们说现在需要Qt 5项目才能向QT变量添加小部件,这就是为什么netbeans中简单的Qt示例不起作用的原因:不能包含QtGui/QApplication->没有这样的文件或目录
I have seen posts in which people say that Qt 5 projects are now required to add widgets to QT variable and this is why simple Qt example in netbeans doesn't work: cannot include QtGui/QApplication -> no such file or directory.
如何将其添加到QT变量?我必须在IDE或.bashrc或某种程度上的每个项目中都这样做吗?
how to add this to QT variable? do I have to do it for each project in IDE or in .bashrc or somehowe?
推荐答案
问题是由于链接错误引起的.这是因为它没有与QtWidgets链接.
the problem was because of link error. it was because it didn't link with QtWidgets.
g++ -m64 -Wl,-rpath,/opt/Qt5.0.1/5.0.1/gcc_64 -Wl,-rpath,/opt/Qt5.0.1/5.0.1/gcc_64/lib -o dist/Debug/GNU-Linux-x86/QtApplication_2 build/Debug/GNU-Linux-x86/main.o -L/usr/X11R6/lib64 -L/opt/Qt5.0.1/5.0.1/gcc_64/lib -lQt5Gui -lQt5Core -lGL -lpthread
首先,我检查了使用QtCore中的内容是否仍然有效.代码是:
first I have checked that using something from QtCore still works. the code was:
#include <QtCore/QCoreApplication>
int main(int argc, char *argv[]) {
// initialize resources, if needed
// Q_INIT_RESOURCE(resfile);
QCoreApplication a(argc, argv);
// create and show your widgets here
return a.exec();
}
很好,所以我知道这只是链接错误. 我仍然不知道要添加什么,因为您在Netbeans的项目属性"的"Qt"选项卡中没有QtWidget.但是反复试验表明,只需在此选项卡(模块)上检查QtOpenGl就足够了,然后将其链接到更多库:
and it was fine, so I knew it is only the linkage error. I still didn't know what to add, as you don't have QtWidget in Qt tab on project Properties in Netbeans. but trial and error showed that it is enough to check the QtOpenGl on this tab (Modules), then it is linked against more libs:
g++ -m64 -Wl,-rpath,/opt/Qt5.0.1/5.0.1/gcc_64 -Wl,-rpath,/opt/Qt5.0.1/5.0.1/gcc_64/lib -o dist/Debug/GNU-Linux-x86/QtApplication_1 build/Debug/GNU-Linux-x86/main.o -L/usr/X11R6/lib64 -L/opt/Qt5.0.1/5.0.1/gcc_64/lib -lQt5OpenGL -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
这篇关于netbeans:如何将小部件添加到QT变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!