Results 1 to 13 of 13

Thread: Qt4 widget and nested layout issue.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Qt4 widget and nested layout issue.

    Quote Originally Posted by bunjee View Post
    I'm deleting the previous one in order to assign my next view.
    OK and where do you call setLayout()?

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

    Post Re: Qt4 widget and nested layout issue.

    Qt Code:
    1. ZeLoginView::ZeLoginView(QWidget *parent, ZeClientController& clientController) :
    2. QWidget(parent)
    3. {
    4. // Login layout
    5. mLoginLayout = new QGridLayout(parent);
    To copy to clipboard, switch view to plain text mode 

    In the constructor of mLoginLayout in ZeLoginView.

    Qt Code:
    1. ZeUserView::ZeUserView(QWidget *parent, ZeUserController& userController) :
    2. QWidget(parent)
    3. {
    4. mUserLayout = new QVBoxLayout(parent);
    To copy to clipboard, switch view to plain text mode 

    In the constructor of mUserLayout in ZeUserView.
    Last edited by bunjee; 18th January 2007 at 13:13. Reason: spelling error

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Qt4 widget and nested layout issue.

    That's an awful way to do that (tightly couples the two widgets). Why not reuse the layout instead of creating a new one?

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

    Post Re: Qt4 widget and nested layout issue.

    In one case I need a QGrid in another a QHBox as main layout.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Qt4 widget and nested layout issue.

    But in both cases they can be children of the parent widget's layout. Your "view" should be a complete widget (having its own layout), not a complete layout. Then you can simply add the widget to the parent's layout.

  6. The following user says thank you to wysota for this useful post:

    bunjee (18th January 2007)

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Qt4 widget and nested layout issue.

    Quote Originally Posted by bunjee View Post
    mLoginLayout = new QGridLayout(parent);
    ...
    mUserLayout = new QVBoxLayout(parent);
    I see, but in this case you end with a widget that has no layout and no child widgets.

  8. The following user says thank you to jacek for this useful post:

    bunjee (18th January 2007)

  9. #7
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Qt products
    Qt4 Qt5
    Thanks
    98
    Thanked 3 Times in 3 Posts

    Smile Re: Qt4 widget and nested layout issue.

    Thanks a lot guys,

    I've changed my approach :
    " One widget has one layout and sticks with it ".

    Even though I don't understand why this option:
    Qt Code:
    1. mLoginLayout = new QGridLayout(parent);
    2. ...
    3. mUserLayout = new QVBoxLayout(parent);
    To copy to clipboard, switch view to plain text mode 
    ... doesn't work.

  10. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Qt4 widget and nested layout issue.

    Quote Originally Posted by bunjee View Post
    Even though I don't understand why this option: [...]
    ... doesn't work.
    Maybe you don't see any other widgets because they are hidden under those empty ZexxxView widgets?

  11. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Qt4 widget and nested layout issue.

    Or you just didn't call show() on them...

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.