PDA

View Full Version : for declaration of struct QToolButton



saman_artorious
11th July 2012, 11:47
why do I receive error when I do not #include for example QToolButton , but rather go for its forward class declaration?



#ifndef PLAYVIDEO_H
#define PLAYVIDEO_H

#include <QWidget>


class QToolButton;
class QGridLayout;
class QHBoxLayout;
class QVBoxLayout;


class PlayVideo : public QWidget
{
Q_OBJECT
public:
PlayVideo(QWidget *parent = 0);

private:
void createButtons();
void createControls();


QToolButton *playButton;
QToolButton *pauseButton;
QToolButton *stopButton;

QGridLayout *controlsLayout;
QHBoxLayout *buttonsLayout;
QVBoxLayout *mainLayout;

};

#endif // PLAYVIDEO_H



error: forward declaration of ‘struct QToolButton’

amleto
11th July 2012, 11:51
I don't think that code will give that error.

(I've just tried it, and it doesn't give that error...)

high_flyer
11th July 2012, 11:52
You need to include the header where you actually use the variable.
The header you posted is valid.
The error probably comes in the implementation where you call a method on your tool button variable.