• 4525阅读
  • 2回复

关于QT编程的疑惑请大虾指点!!!!!!!!!!!!!! [复制链接]

上一主题 下一主题
离线duuliyan
 
只看楼主 倒序阅读 楼主  发表于: 2009-05-16
#include<QApplication>
#include<QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv[]);
QLabel *label=new QLabel("hello qt");
label->show();
return app.exec();
}
在编译的时候并不能通过会有错误提示!
错误提示如下:
Running build steps for project hell...
Creating gdb macros library...
Configuration unchanged, skipping QMake step.
Starting: C:/Qt/2009.01/mingw/bin/mingw32-make.exe -w
mingw32-make: Entering directory `C:/hell'
C:/Qt/2009.01/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/hell'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\Qt\2009.01\qt\include\QtCore" -I"..\Qt\2009.01\qt\include\QtGui" -I"..\Qt\2009.01\qt\include" -I"." -I"..\Qt\2009.01\qt\include\ActiveQt" -I"debug" -I"." -I"..\Qt\2009.01\qt\mkspecs\win32-g++" -o debug\hell.o hell.cpp
hell.cpp: In function `int qMain(int, char**)':
hell.cpp:8: error: request for member `show' in `label', which is of non-class type `QLabel*'
mingw32-make[1]: Leaving directory `C:/hell'
mingw32-make: Leaving directory `C:/hell'
mingw32-make[1]: *** [debug/hell.o] Error 1
mingw32-make: *** [debug] Error 2
Exited with code 2.
Error while building project hell
When executing build step 'Make'
但是把代码改成如下:
#include<QApplication>
#include<QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv[]);
QLabel label("hello qt");
label->show();
return app.exec();
}
时能过顺利编译!
请大虾解释一下!
谢谢!
离线jorneyr

只看该作者 1楼 发表于: 2009-05-18
//#include<QApplication>
//#include<QLabel>
#include<QtGui/QApplication>
#include<QtGui/QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv); // ********修改
QLabel *label=new QLabel("hello qt");
label->show();
return app.exec();
}
离线anycall
只看该作者 2楼 发表于: 2009-05-20
楼上正解,参数中多了个[]
快速回复
限100 字节
 
上一个 下一个