[Qt-interest] can not set Layout correctly

yanqzhi at gmail.com yanqzhi at gmail.com
Wed Aug 25 08:15:35 CEST 2010


I have a class subclass QDialog

class MyDiaolog : public QDialog
{
 Q_OBJECT
public:
 MyDiaolog(QWidget *parent = NULL);
 ~MyDiaolog();
protected:
 QPushButton * mButton;
 QGridLayout * mLayout; 
};

in the constructor

MyDiaolog::MyDiaolog(QWidget *parent)
 : QDialog(parent)
{
 mButton = new QPushButton("testButton", this);
 mLayout = new QGridLayout(this);
 mLayout->addWidget(mButton, 0, 0, 1, 1);
}

and I have another class which subclass the class MyDialog

class TestDialog : public MyDiaolog
{
 Q_OBJECT
public:
 TestDialog(QWidget *parent = NULL);
 ~TestDialog ();
private:
 QPushButton * mButton1;
 QGridLayout * mRightLayou;
 QHBoxLayout * mHLayout;
};

int the constructor

Dialog::Dialog(QWidget *parent)
 : MyDiaolog(parent)
{
 mButton1 = new QPushButton("right", this);
 mRightLayou = new QGridLayout(this);
 mRightLayou->addWidget(mButton1, 0, 0, 1, 1);
 mHLayout = new QHBoxLayout(this);
 mHLayout->addLayout(mLayout);
 mHLayout->addLayout(mRightLayou);
 setLayout(mHLayout);
}

I expect that the buttons layout side by side from left to right,
but in fact the TestDialog's layout() return the mLayout;

How can I set the TestDialog's layout as mHlayout?

Thank a lot!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100825/4754eb02/attachment.html 


More information about the Qt-interest-old mailing list