You set create a "main" layout and within that you can add another layout if you want to, tell us more about what are you trying to achieve and also take a look at documentation
Also, you can use forward declaration in headers for all classes that have only pointers or references or are passed as parameter to member function (this makes the compilation faster for bigger projects):
#ifndef DESENHO_H
#define DESENHO_H
#include <QWidget> //you need this header included because you derive from QWidget
/* you don't need these headers included in your header
-- include those in the .cpp file
#include <QVBoxLayout>
#include <QSpacerItem>
#include <QPushButton>
*/
//here you only use forward declaration:
//and so on
{
Q_OBJECT
public:
~Widget();
protected:
private:
};
#endif
#ifndef DESENHO_H
#define DESENHO_H
#include <QWidget> //you need this header included because you derive from QWidget
/* you don't need these headers included in your header
-- include those in the .cpp file
#include <QVBoxLayout>
#include <QSpacerItem>
#include <QPushButton>
*/
//here you only use forward declaration:
class QVBoxLayout;
class QPushButton;
//and so on
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = 0);
~Widget();
void draw(QPainter *painter);
protected:
void paintEvent(QPaintEvent *event);
private:
QPushButton *btn1, *btn2;
QSpacerItem *spacer;
QVBoxLayout *verticalLayout;
};
#endif
To copy to clipboard, switch view to plain text mode
Bookmarks