• 4307阅读
  • 2回复

新手提问,Qt Creator 2.0.1中运行精通QT4编程一书中第一个qt程序报错,什么原因? [复制链接]

上一主题 下一主题
离线refazy
 
只看楼主 倒序阅读 楼主  发表于: 2011-03-11
#include <QtGui/QApplication>[pre]#include <QtGui/QWidget>[/pre][pre]#include <QtGui/QLabel>[/pre][pre][/pre][pre]#include <QtCore/QTextCodec>[/pre][pre][/pre][pre]int main(int argc, char* argv[])[/pre][pre][/pre][pre]{[/pre][pre][/pre][pre]    QApplication app(argc,argv);[/pre][pre]    QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030"));[/pre][pre]    QWidget* pWidget =new QWidget;[/pre][pre]    QLabel label(pWidget);[/pre][pre]    label.setText(QObject::tr("同一个世界,同一个梦想"));[/pre][pre]    pWidget->show();[/pre][pre]    return app.exec();[/pre][pre]}[/pre][pre] [/pre][pre] [/pre][pre]报的错都是undefined reference to '_imp_zN12QApplicationC1ERiPpci'之类的错误。我用的是Qt Creator 2.0.1[/pre][pre],在windows平台的。[/pre][pre] [/pre][pre]请问什么原因 啊?[/pre][pre] [/pre][pre]第一次接触这个,很多不懂的[/pre]
离线refazy
只看该作者 1楼 发表于: 2011-03-11
#include <QtGui/QApplication>
#include <QtGui/QWidget>
#include <QtGui/QLabel>

#include <QtCore/QTextCodec>

int main(int argc, char* argv[])

{

QApplication app(argc,argv);
QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030"));
QWidget* pWidget =new QWidget;
QLabel label(pWidget);
label.setText(QObject::tr("同一个世界,同一个梦想"));
pWidget->show();
return app.exec();
}
离线refazy
只看该作者 2楼 发表于: 2011-03-11
我已经搞定了
参见此贴
http://www.yafeilinux.com/?p=14
快速回复
限100 字节
 
上一个 下一个