分页: 1 / 1

新手在QT编译的时候出的问题,急求高手解决!

发表于 : 2010-11-04 23:19
har4
在编辑helloqt中,代码是抄书上的,应该没问题的,但是编译过程中出现如下问题:

wyk3.cpp:2:22: error: QpushButton: 没有那个文件或目录
wyk3.cpp:3: error: conflicting declaration ‘int** argc’
wyk3.cpp:3: error: ‘argc’ has a previous declaration as ‘int argc’
wyk3.cpp:3: warning: ‘int main(int)’ takes only zero or two arguments
wyk3.cpp: In function ‘int main(int)’:
wyk3.cpp:5: error: ‘argv’ was not declared in this scope
wyk3.cpp:5: error: ‘QPushbutton’ was not declared in this scope
wyk3.cpp:5: error: expected ‘;’ before ‘pushbutton’
wyk3.cpp:6: error: ‘pushButton’ was not declared in this scope
wyk3.cpp:7: error: ‘Q0bject’ has not been declared

我敲的代码是:
#include<QApplication>
#include<QpushButton>
int main(int argc,char *argc[])
{
QApplication app(argc,argv);
QPushbutton pushbutton(Q0bject::tr("hello Qt!"));
pushButton.show();
Q0bject::connect(&pushButton,SIGNAL(clicked()),&app,SLOT(quit()));
return app.exec();
}

Re: 新手在QT编译的时候出的问题,急求高手解决!

发表于 : 2010-11-05 10:10
linlee
#include<QpushButton>改成#include<QPushButton> ?
猜的~

Re: 新手在QT编译的时候出的问题,急求高手解决!

发表于 : 2010-11-07 9:17
crh8539
你这个程序不完整呢!应该要申明个构造函数的!
你应该找个完整的,而且能编译通过的工程,学习学习!
我也是刚学 :em06

Re: 新手在QT编译的时候出的问题,急求高手解决!

发表于 : 2010-11-22 17:50
darouwan
#include <QtGui/QPushButton> 首先要这么些~~~不知道是否一定这样写 但这样一定正确
还有 按钮要这么新建
QPushButton Button = new QPushButton(...);

Re: 新手在QT编译的时候出的问题,急求高手解决!

发表于 : 2010-11-22 17:57
Bill Lee
你是怎么编译的,应该是

代码: 全选

qmake -project
qmake
make

Re: 新手在QT编译的时候出的问题,急求高手解决!

发表于 : 2010-11-22 21:07
eexpress
不如直接用qtcreator。
虽然不能自动设置好connect,其他的方面,至少不需要你去折腾。

Re: 新手在QT编译的时候出的问题,急求高手解决!

发表于 : 2010-11-24 1:29
自由建客
抄都抄错了,随便看看,最后一行,Q0bject ,注意那个是大写字母 欧 ,不是数字 零 。

Re: 新手在QT编译的时候出的问题,急求高手解决!

发表于 : 2010-11-24 16:34
水木杨
你这个错误还真多……根据错误提示一步一步排查就行了,比如第一个是QApplication,main函数中参数名字有冲突……