Results 1 to 2 of 2

Thread: QTabWidget Placement and Display

  1. #1
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question QTabWidget Placement and Display

    Greetings,

    I have a program that currently stacks 2 QGroupBox objects and a QFrame object vertically on the central widget of the QMainWindow. A last minute UI change requires me to place the QGroupBox objects on a QTabWidget.

    Here I'm running into tab widget problems:

    1) I have been unable to position the QTabWidget on the main windows central widget without having it overwrite part of the main menu area. How can I position the tab widget so the main menu will be fully shown?

    2) The QTabWidget appears to overwrite the QFrame in main window. It actually seems to extend well beyond the window both vertically and horizontally. Previously, with just the QGroupBox objects (no tab widget) I could use the following code to show both group boxes and frame:
    Qt Code:
    1. QFrame* qFrame = new QFrame( this );
    2. qFrame->setFrameRect( QRect( 0, 0, 0, 0 ) );
    3. qFrame->setFrameStyle( QFrame::Box | QFrame::Plain );
    4.  
    5. // Checkbox in frame
    6. m_onlineChk = new QCheckBox( "Show Online Table ", qFrame );
    7. m_onlineChk->setToolTip( "Show/Hide Online Table" );
    8. connect( m_onlineChk, SIGNAL( clicked() ), this, SLOT( onlineClicked() ) );
    9. m_onlineChk->setCheckState( Qt::Checked );
    10.  
    11. QHBoxLayout* frameLayout = new QHBoxLayout( qFrame );
    12. frameLayout->setSizeConstraint( QLayout::SetMaximumSize );
    13. frameLayout->addWidget( m_onlineChk, 0, Qt::AlignRight );
    14. frameLayout->insertStretch( 0, 0 );
    15. qFrame->setLayout( frameLayout );
    16.  
    17. m_centralLayout = new QGridLayout;
    18.  
    19. // Configuration Table is 1st
    20. m_centralLayout->addWidget( m_cfgGroupBox, 1, 0, 1, 2 );
    21. m_centralLayout->setRowMinimumHeight( 1, 300 );
    22.  
    23. // Online Table is in middle
    24. m_centralLayout->addWidget(m_olnGroupBox, 2, 0, 1, 2);
    25. m_centralLayout->setRowMinimumHeight( 2, 300 );
    26.  
    27. // Frame is on bottom (just above the status bar)
    28. m_centralLayout->addWidget( qFrame, 3, 0, 1, 2 );
    29. m_centralLayout->setRowMinimumHeight( 3, 30 );
    To copy to clipboard, switch view to plain text mode 

    I'm using this code to try and display the tab widget on top and the frame on the bottom of the main windows central widget:
    Qt Code:
    1. m_centralLayout = new QGridLayout;
    2.  
    3. // Tab widget is 1st
    4. m_centralLayout->addWidget( m_tabWidget, 1, 0, 1, 1);
    5. m_centralLayout->setRowMinimumHeight( 1, 300 );
    6.  
    7. // Frame is on bottom (just above the status bar)
    8. m_centralLayout->addWidget( qFrame, 2, 0, 1, 1 );
    9. m_centralLayout->setRowMinimumHeight( 2, 30 );
    10.  
    11. m_pCentralWidget->setLayout( m_centralLayout );
    To copy to clipboard, switch view to plain text mode 

    How can I add both the tab widget and frame to the central widget?

  2. #2
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Talking Re: QTabWidget Placement and Display

    Solved!

    If I delay setting the central widget until after creating the tab widget, frame and layout, it doesn't overwrite the main menu. Weird...

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.