Hey all,
I've got a problem with a nested layout.
First off I'm creating the main widget items.
Then I'm passsing it to my first view to create its Qt components :
ZeLoginView
::ZeLoginView(QWidget *parent, ZeClientController
& clientController
) :
ZeLoginView::ZeLoginView(QWidget *parent, ZeClientController& clientController) :
QWidget(parent)
To copy to clipboard, switch view to plain text mode
At the end of the process I'm deleting this view and free the layout of my main widget :
void ZeGlobalController::SetView(ViewMode viewMode)
{
delete this->layout(); [...]
}
void ZeGlobalController::SetView(ViewMode viewMode)
{
delete this->layout(); [...]
}
To copy to clipboard, switch view to plain text mode
Finally I'm passing my main widget to another view with a "Nested layout" :
ZeUserView
::ZeUserView(QWidget *parent, ZeUserController
& userController
) : {
ZeLog::Get()->AddLine("--- Creating the user view ---\n");
// User Infos
// User picture
mUserPictureLabel
= new QLabel;
mUserPictureLabel
->setPixmap
(QPixmap("zeData/profil_no_pic.jpg"));
mUserInfoLayout->addWidget(mUserPictureLabel, 1, 1, Qt::AlignCenter);
// Login label
mLoginLabel->setText(tr("Login"));
mUserInfoLayout->addWidget(mLoginLabel, 2, 1, Qt::AlignCenter);
// Message combo box
mMessageComboBox->setFixedWidth(100);
mUserInfoLayout->addWidget(mMessageComboBox, 3, 1, Qt::AlignCenter);
// Status combo box
mStatusComboBox->setEditable(true);
mStatusComboBox->setFixedWidth(100);
mUserInfoLayout->addWidget(mStatusComboBox, 4, 1, Qt::AlignCenter);
// Layout stretch
mUserInfoLayout->setColumnStretch(0, 10);
mUserInfoLayout->setColumnStretch(2, 10);
mUserLayout->addLayout(mUserInfoLayout);
}
ZeUserView::ZeUserView(QWidget *parent, ZeUserController& userController) :
QWidget(parent)
{
ZeLog::Get()->AddLine("--- Creating the user view ---\n");
mUserLayout = new QVBoxLayout(parent);
// User Infos
mUserInfoLayout = new QGridLayout;
// User picture
mUserPictureLabel = new QLabel;
mUserPictureLabel->setPixmap(QPixmap("zeData/profil_no_pic.jpg"));
mUserInfoLayout->addWidget(mUserPictureLabel, 1, 1, Qt::AlignCenter);
// Login label
mLoginLabel = new QLabel;
mLoginLabel->setText(tr("Login"));
mUserInfoLayout->addWidget(mLoginLabel, 2, 1, Qt::AlignCenter);
// Message combo box
mMessageComboBox = new QLineEdit;
mMessageComboBox->setFixedWidth(100);
mUserInfoLayout->addWidget(mMessageComboBox, 3, 1, Qt::AlignCenter);
// Status combo box
mStatusComboBox = new QComboBox;
mStatusComboBox->setEditable(true);
mStatusComboBox->setFixedWidth(100);
mUserInfoLayout->addWidget(mStatusComboBox, 4, 1, Qt::AlignCenter);
// Layout stretch
mUserInfoLayout->setColumnStretch(0, 10);
mUserInfoLayout->setColumnStretch(2, 10);
mUserLayout->addLayout(mUserInfoLayout);
}
To copy to clipboard, switch view to plain text mode
For some reason the nested layout : mUserInfoLayout, never appears : blank window.
And even more strange, it's working in two cases:
1. If I don't use nested layout to show my components.
2. Working with nested stuff If I'm creating the second view at first.
Looks like something is messed up between the first view and the second creation.
There must be something wrong with the main widget, is there anything I could have forgot beside the delete layout() ?
In advance thanks.
Ben.
Bookmarks