duduqq 发表于 2008-3-21 17:20:34

大侠们帮忙看看,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’

duduqq 发表于 2008-3-21 18:11:02

原来是QTimer头文件和class QTimer的先后顺序的问题,把头文件#include在同一个文件里就行了。
页: [1]
查看完整版本: 大侠们帮忙看看,QT定时器的问题