• 40113阅读
  • 12回复

各位帮忙看看,为什我老出这样的问题 error: invalid use of incomplete type ‘struct QTimer’ [复制链接]

上一主题 下一主题
离线duduqq
 

只看楼主 倒序阅读 楼主  发表于: 2008-03-21
— 本帖被 XChinux 执行加亮操作(2008-07-17) —
是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’
离线浪漫天使
只看该作者 1楼 发表于: 2008-03-21
QTimer头文件和class QTimer的先后顺序的问题,换一下顺序看看
离线duduqq

只看该作者 2楼 发表于: 2008-03-21
真的如楼上那位大侠所说的一样,也真是怪事啊,我把头文件放到写到另一个文件里面,虽然会出现这样的事。谢谢了。
离线hu851217

只看该作者 3楼 发表于: 2010-08-13
launcherbutton.cpp: In member function ‘virtual void LauncherButton::dragEnterEvent(QGraphicsSceneDragDropEvent*)’:
launcherbutton.cpp:58:12: error: invalid use of incomplete type ‘struct QGraphicsSceneDragDropEvent’
/usr/include/QtGui/qgraphicsitem.h:70:7: error: forward declaration of ‘struct QGraphicsSceneDragDropEvent’



楼上的大哥,我也碰到了同样的问题啊,把你的解决方法分享下阿!!!!!!
离线dbzhang800

只看该作者 4楼 发表于: 2010-08-13
引用第3楼hu851217于2010-08-13 12:22发表的  :
launcherbutton.cpp: In member function ‘virtual void LauncherButton::dragEnterEvent(QGraphicsSceneDragDropEvent*)’:
launcherbutton.cpp:58:12: error: invalid use of incomplete type ‘struct QGraphicsSceneDragDropEvent’
/usr/include/QtGui/qgraphicsitem.h:70:7: error: forward declaration of ‘struct QGraphicsSceneDragDropEvent’
.......


要包含用到的头文件
[pre] #include <QGraphicsSceneDragDropEvent>[/pre]
离线hu851217

只看该作者 5楼 发表于: 2010-08-17
楼上的大哥,加了[pre] #include <QGraphicsSceneDragDropEvent>[/pre] 头文件后错误更多,最后我加了个<QtGui> 就好了,至今没搞明白!
离线benbenmajia

只看该作者 6楼 发表于: 2010-08-17
回 5楼(hu851217) 的帖子
是你的头文件没有加对..db是copy过来的代码,QTGUI包含了QT中GUI方面的所有类的头文件当然可以
安然.....
离线永恒国度
只看该作者 7楼 发表于: 2011-03-03
回 6楼(benbenmajia) 的帖子
但是我的程序中加了#include<QtGui>却没有用啊
离线roywillow

只看该作者 8楼 发表于: 2011-03-03
如果是单看标题的话,好像是没有#include <QTimer>
我在用qDebug()的时候经常出现这句话,然后就不得不加上#include <QDebug>
专业维修核潜艇,回收二手航母、二手航天飞机,大修核反应堆,拆洗导弹发动机更换机油,无人侦察机手动挡改自动,航天飞机保养换三滤,飞碟外太空年检 ,各型号导弹加装迎宾踏板,高空作业擦洗卫星表面除尘、打蜡及抛光,东风全系列巡航导弹。并提供原子对撞机。量大从优,有正规发票。
离线jptiancai

只看该作者 9楼 发表于: 2011-09-21
注意加 #include <QtGui> 在那个文件里了。。
只看该作者 10楼 发表于: 2012-03-17
ui_mainwindow.h: In member function ‘void Ui_MainWindow::setupUi(QMainWindow*)’:
ui_mainwindow.h:72: error: invalid use of incomplete type ‘struct QDockWidget’
/witech/builddir/sdk/qtopiacore/target/include/QtGui/qmainwindow.h:59: error: forward declaration of ‘struct QDockWidget’
ui_mainwindow.h:73: error: invalid use of incomplete type ‘struct QDockWidget’

我也出现了这个问题,困扰了我一个晚上,没有解决,希望高手可以指点以下
有缘相聚在这个论坛
只看该作者 11楼 发表于: 2012-03-17
引用第10楼闪电侠风行于2012-03-17 10:23发表的  :
ui_mainwindow.h: In member function ‘void Ui_MainWindow::setupUi(QMainWindow*)’:
ui_mainwindow.h:72: error: invalid use of incomplete type ‘struct QDockWidget’
/witech/builddir/sdk/qtopiacore/target/include/QtGui/qmainwindow.h:59: error: forward declaration of ‘struct QDockWidget’
ui_mainwindow.h:73: error: invalid use of incomplete type ‘struct QDockWidget’
.......

我在代码中加了#include<QtGui>   #include<QDockWidget>   #include<QMainWindow> 但是都不管用。
我在qdesigner中拖放了一个QDockWidget,函数源代码中没有关于它的代码
有缘相聚在这个论坛
离线ls159789
只看该作者 12楼 发表于: 2012-08-17
我也遇到这样的问题,刚刚加了
#include <QTimer>
#include <QTime>
这俩兄弟,问题就解决了!
快速回复
限100 字节
 
上一个 下一个