Results 1 to 13 of 13

Thread: Qt4 widget and nested layout issue.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Qt products
    Qt4 Qt5
    Thanks
    98
    Thanked 3 Times in 3 Posts

    Question Qt4 widget and nested layout issue.

    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 :

    Qt Code:
    1. ZeLoginView::ZeLoginView(QWidget *parent, ZeClientController& clientController) :
    2. 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 :
    Qt Code:
    1. void ZeGlobalController::SetView(ViewMode viewMode)
    2. {
    3. delete this->layout(); [...]
    4. }
    To copy to clipboard, switch view to plain text mode 

    Finally I'm passing my main widget to another view with a "Nested layout" :
    Qt Code:
    1. ZeUserView::ZeUserView(QWidget *parent, ZeUserController& userController) :
    2. QWidget(parent)
    3. {
    4. ZeLog::Get()->AddLine("--- Creating the user view ---\n");
    5.  
    6. mUserLayout = new QVBoxLayout(parent);
    7.  
    8. // User Infos
    9.  
    10. mUserInfoLayout = new QGridLayout;
    11.  
    12. // User picture
    13. mUserPictureLabel = new QLabel;
    14. mUserPictureLabel->setPixmap(QPixmap("zeData/profil_no_pic.jpg"));
    15. mUserInfoLayout->addWidget(mUserPictureLabel, 1, 1, Qt::AlignCenter);
    16.  
    17. // Login label
    18. mLoginLabel = new QLabel;
    19. mLoginLabel->setText(tr("Login"));
    20. mUserInfoLayout->addWidget(mLoginLabel, 2, 1, Qt::AlignCenter);
    21.  
    22. // Message combo box
    23. mMessageComboBox = new QLineEdit;
    24. mMessageComboBox->setFixedWidth(100);
    25. mUserInfoLayout->addWidget(mMessageComboBox, 3, 1, Qt::AlignCenter);
    26.  
    27. // Status combo box
    28. mStatusComboBox = new QComboBox;
    29. mStatusComboBox->setEditable(true);
    30. mStatusComboBox->setFixedWidth(100);
    31. mUserInfoLayout->addWidget(mStatusComboBox, 4, 1, Qt::AlignCenter);
    32.  
    33. // Layout stretch
    34. mUserInfoLayout->setColumnStretch(0, 10);
    35. mUserInfoLayout->setColumnStretch(2, 10);
    36.  
    37. mUserLayout->addLayout(mUserInfoLayout);
    38.  
    39. }
    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.
    Last edited by bunjee; 18th January 2007 at 13:08. Reason: spelling error

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.