|
|
* On 13.08.2007 15:20, Daniel Albuschat wrote:
[...]
Here's the way I do it, which is, imho, conceptually better:
class MyWidget: public QWidget
{
Q_OBJECT
private:
QLineEdit le_name;
QLabel l_name;
QVBoxLayout layout;
public:
MyWidget(QWidget *parent):
QWidget(parent),
le_name(0),
l_name(0) {
l_name.setText("Name: ");
layout.addWidget(&l_name);
layout.addWidget(&le_name);
setLayout(&layout);
}
};
But the stack order seems to be very important. My example leads to an
segmentation fault when the window is destroyed. The solution is to
transpose the two variables below.
class MyWidget : public QWidget
{
Q_OBJECT
QGridLayout m_innerLayout;
QGroupBox m_groupBox;
public:
MyWidget(QWidget* = 0);
virtual ~MyWidget();
};
MyWidget::MyWidget(QWidget* a_parent)
: QWidget(a_parent),
m_innerLayout(0),
m_groupBox(0)
{
m_groupBox.setLayout(&m_innerLayout);
}
Regards,
Lars
--
To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
"unsubscribe" in the subject or the body.
List archive and information: http://lists.trolltech.com/qt-interest/
|
|