seux
8th September 2011, 22:14
Hello everyone,
imagine that i have something like this in a class
//...
private:
QWidget *widget;
and in one of the public functions i want to add other widgets like maybe a QPushButton and a QVBoxLayout. How can i do that?
For the QPushButton i tried it this way:
QPushButton *btn = new QPushButton("Hello");
widget->layout()->addWidget(btn);
But the widget has currently no layout, so i cannot try it out...
Is it possible to do it this way, and how can i apply a layout to the widget?
imagine that i have something like this in a class
//...
private:
QWidget *widget;
and in one of the public functions i want to add other widgets like maybe a QPushButton and a QVBoxLayout. How can i do that?
For the QPushButton i tried it this way:
QPushButton *btn = new QPushButton("Hello");
widget->layout()->addWidget(btn);
But the widget has currently no layout, so i cannot try it out...
Is it possible to do it this way, and how can i apply a layout to the widget?