Frostorator
31st July 2011, 03:16
I was trying to use qobject-embedded timer and get this errors:
...\tickingqmessagebox.cpp:5: error: invalid use of incomplete type 'struct QTimerEvent'
...\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtCore\qo bject.h:63: error: forward declaration of 'struct QTimerEvent'
Minimal code (error highlited by comment):
tickingqmessagebox.h
#ifndef TICKINGQMESSAGEBOX_H
#define TICKINGQMESSAGEBOX_H
#include <QMessageBox>
class TickingQMessageBox : public QMessageBox
{
Q_OBJECT
public:
explicit TickingQMessageBox(QWidget *parent = 0) : QMessageBox(parent) {};
protected:
void timerEvent(QTimerEvent *);
};
#endif // TICKINGQMESSAGEBOX_H
tickingqmessagebox.cpp
#include "tickingqmessagebox.h"
void TickingQMessageBox::timerEvent(QTimerEvent * event)
{
if (event->timerId==0) {} // <-- error appears here
}
main.cpp and .pro file are automatically generated. compiling only to desktop target.
If i try to move timerEvent implementaion from .cpp to .h file, I get this error (on the same line of code):
error: invalid use of member (did you forget the '&' ?)
P.S. I use the latest version of Qt SDK and tried to compile it with Qt Creator.
...\tickingqmessagebox.cpp:5: error: invalid use of incomplete type 'struct QTimerEvent'
...\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtCore\qo bject.h:63: error: forward declaration of 'struct QTimerEvent'
Minimal code (error highlited by comment):
tickingqmessagebox.h
#ifndef TICKINGQMESSAGEBOX_H
#define TICKINGQMESSAGEBOX_H
#include <QMessageBox>
class TickingQMessageBox : public QMessageBox
{
Q_OBJECT
public:
explicit TickingQMessageBox(QWidget *parent = 0) : QMessageBox(parent) {};
protected:
void timerEvent(QTimerEvent *);
};
#endif // TICKINGQMESSAGEBOX_H
tickingqmessagebox.cpp
#include "tickingqmessagebox.h"
void TickingQMessageBox::timerEvent(QTimerEvent * event)
{
if (event->timerId==0) {} // <-- error appears here
}
main.cpp and .pro file are automatically generated. compiling only to desktop target.
If i try to move timerEvent implementaion from .cpp to .h file, I get this error (on the same line of code):
error: invalid use of member (did you forget the '&' ?)
P.S. I use the latest version of Qt SDK and tried to compile it with Qt Creator.