首页| 论坛| 消息

标题:【提问】我是新手,请大家帮我看一下这是怎么回事
作者:xcgwy
日期:2006-02-16 18:02
内容:

main.cpp:
#include
#include
#include
#include
#include
class CMywin : public QWidget
{
Q_OBJECT
public:
CMywin(QWidget *parent=0);
QLabel *label1;
QPushButton *button1;
QPushButton *button2;
private slot:
void button1click();
void button2click();
};
CMywin::CMywin(QWidget *parent)
:QWidget(parent)
{
label1=new QLabel(tr("label1"));
button1 = new QPushButton(tr("button1"));
connect(button1, SIGNAL(clicked()), this, SLOT(button1click()));
button2 = new QPushButton(tr("button2"));
connect(button2, SIGNAL(clicked()), this, SLOT(button2click()));
QHBoxLayout *buttonsLayout = new QHBoxLayout;
buttonsLayout->addStretch();
buttonsLayout->addWidget(label1);
buttonsLayout->addWidget(button1);
buttonsLayout->addWidget(button2);
setLayout(buttonsLayout);
}
void CMywin::button1click()
{
label1->setText("hello");
}
void CMywin::button2click()
{

}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
CMywin mywin;
mywin.show();
return app.exec();
}
命令如下:
qmake -project 正常
qmake 正常
make
错误信息:
E:\test>make
make -f Makefile.Debug
make[1]: Entering directory `E:/test'
g++ -c -g -g -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL
-DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"D:/Qt/QT4.1.
0/include/QtCore" -I"D:/Qt/QT4.1.0/include/QtGui" -I"D:/Qt/QT4.1.0/include" -I".
" -I"D:/Qt/QT4.1.0/include/ActiveQt" -I"debug" -I"." -I"D:/Qt/QT4.1.0/mkspecs/wi
n32-g++" -o ..


#1 [xuxinshao 02-16 18:15]
缺少moc文件
#2 [xcgwy 02-16 18:17]
下面是引用xuxinshao于2006-02-16 10:15发表的:
缺少moc文件
先谢过。
在QT安装目录下bin时有moc.exe啊
那现在该怎么办呢?
#3 [fanyu 02-16 20:05]
你用发行版来编译试试看,qt 4 for MingW,系统默认是没有qt的调试库的,只有发行库。
即make -f Makefile.release来编译。
还有就是类定义和实现要分开,即分别写在.h和cpp文件里,写在一个文件里是不行的。
#4 [xcgwy 02-16 22:51]
下面是引用fanyu于2006-02-16 12:05发表的:
你用发行版来编译试试看,qt 4 for MingW,系统默认是没有qt的调试库的,只有发行库。
即make -f Makefile.release来编译。
还有就是类定义和实现要分开,即分别写在.h和cpp文件里,写在一个文件里是不行的。
还是不行,不过我编译中的tutorial中的t7是能编译过的。
我用的是QT4.1.0。
#5 [renstone 02-17 06:38]
private slot:
private slots:
??
这种问题属于语法错误。是在编译期发生的,一般遇到这种问题,应当仔细检查语法。

<< 1 2 >> (1/2)

回复 发表
主题 版块