大侠们帮忙看看,QT定时器的问题
是QT定时器的问题,不知为什我就是老编译不了,老报错源码:
timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(repaint()));
timer->start(3000);
错误代:
mywindow.cpp: In constructor ‘MyWindow::MyWindow()’:
mywindow.cpp:66: error: invalid use of incomplete type ‘struct QTimer’
/usr/include/QtGui/qwindowdefs.h:78: error: forward declaration of ‘struct QTimer’
mywindow.cpp:67: error: no matching function for call to ‘MyWindow::connect(QTimer*&, const char , MyWindow* const, const char )’
/usr/include/QtCore/qobject.h:191: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
/usr/include/QtCore/qobject.h:292: note: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
mywindow.cpp:68: error: invalid use of incomplete type ‘struct QTimer’
/usr/include/QtGui/qwindowdefs.h:78: error: forward declaration of ‘struct QTimer’ 原来是QTimer头文件和class QTimer的先后顺序的问题,把头文件#include在同一个文件里就行了。
页:
[1]