Results 1 to 3 of 3

Thread: Nested Layout

  1. #1
    Join Date
    Mar 2008
    Posts
    29
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Nested Layout

    Hi,
    I use a nested layout widget instance in my subclass of QMainWindow. At runtime I get the following message on console:

    QLayout: Attempting to add QLayout "" to SchulungsplanParentWidget "", which already has a layout

    Do you know why ? The gui seems to be correct...

    This is my constuctor of the Widget class which is the center in my QMainWindow:
    Qt Code:
    1. SchulungsplanParentWidget::SchulungsplanParentWidget(QDate& p_startViewDate, QDate& p_endViewDate, QWidget *p_parent)
    2. : QWidget(p_parent)
    3. {
    4. QVBoxLayout *vBoxLayout = new QVBoxLayout(this);
    5. QHBoxLayout *hBoxLayout = new QHBoxLayout(this);
    6.  
    7. m_startViewDateLabel= new QLabel("Schulungsplan VON:");
    8. m_startViewDateEdit = new QDateEdit(p_startViewDate);
    9. m_endViewDateLabel = new QLabel("Schulungsplan BIS:");
    10. m_endViewDateEdit = new QDateEdit(p_endViewDate);
    11. m_uebernehmenButton = new QPushButton("Uebernehmen");
    12.  
    13. m_spTableView = new SchulungsplanView(this);
    14.  
    15. hBoxLayout->addWidget(m_startViewDateLabel, 1, Qt::AlignLeft);
    16. hBoxLayout->addWidget(m_startViewDateEdit, 2, Qt::AlignLeft);
    17. hBoxLayout->addWidget(m_endViewDateLabel, 1, Qt::AlignLeft);
    18. hBoxLayout->addWidget(m_endViewDateEdit, 2, Qt::AlignLeft);
    19. hBoxLayout->addWidget(m_uebernehmenButton, 1, Qt::AlignLeft);
    20.  
    21. vBoxLayout->addLayout(hBoxLayout);
    22. vBoxLayout->addWidget(m_spTableView);
    23.  
    24. connect( m_uebernehmenButton, SIGNAL(clicked() ),
    25. this, SLOT(uebernehmenButtonPressed() ) );
    26. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Nested Layout

    change lines 4 , 5 as -

    Qt Code:
    1. QVBoxLayout *vBoxLayout = new QVBoxLayout();
    2. QHBoxLayout *hBoxLayout = new QHBoxLayout();
    To copy to clipboard, switch view to plain text mode 

    and add to line 23

    Qt Code:
    1. setLayout(vBoxLayout);
    To copy to clipboard, switch view to plain text mode 

    Hope it helps

  3. #3
    Join Date
    Mar 2008
    Posts
    29
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Nested Layout

    ok ;-) thank you... so it works:
    Qt Code:
    1. SchulungsplanParentWidget::SchulungsplanParentWidget(QDate& p_startViewDate, QDate& p_endViewDate, QWidget *p_parent)
    2. : QWidget(p_parent)
    3. {
    4. QVBoxLayout *vBoxLayout = new QVBoxLayout(this);
    5. QHBoxLayout *hBoxLayout = new QHBoxLayout();
    6.  
    7. ...
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. changing layout of a widget
    By mikro in forum Qt Programming
    Replies: 10
    Last Post: 4th August 2009, 21:21
  2. Qt layout memory issue
    By bunjee in forum Qt Programming
    Replies: 9
    Last Post: 25th August 2007, 18:11
  3. Resizing problems when applying a layout
    By JimBrown in forum Newbie
    Replies: 1
    Last Post: 21st February 2007, 23:54
  4. Qt4 widget and nested layout issue.
    By bunjee in forum Qt Programming
    Replies: 12
    Last Post: 18th January 2007, 21:29
  5. "dynamic" layout
    By hulk in forum Qt Programming
    Replies: 2
    Last Post: 9th May 2006, 08:16

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.