QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2822|回复: 1

大侠们帮忙看看,QT定时器的问题

[复制链接]
发表于 2008-3-21 17:20:34 | 显示全部楼层 |阅读模式
是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 [11], MyWindow* const, const char [11])’
/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’
 楼主| 发表于 2008-3-21 18:11:02 | 显示全部楼层
原来是QTimer头文件和class QTimer的先后顺序的问题,把头文件#include在同一个文件里就行了。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-4-27 02:27 , Processed in 0.120795 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表