Results 1 to 12 of 12

Thread: Window doesn't expand to show all elements of QHBoxLayout

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2007
    Posts
    8
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Window doesn't expand to show all elements of QHBoxLayout

    I'm building a tic-tac-toe game.

    In my main window, I've got a QHBoxLayout holding the board (UIBoard), and the settings (which now consist of a start and quit button). uiSettings uses a QGroupBox and a QVBoxLayout in order to hold the start and quit buttons.

    Everything works, but when I start the program, I have to manually enlarge the window so that everything is shown -- not just the board.

    Here's the code:

    uiMain.hpp
    Qt Code:
    1. #ifndef UIMAIN_HPP_
    2. #define UIMAIN_HPP_
    3.  
    4. #include <QPushButton>
    5. #include <QHBoxLayout>
    6. #include <QVBoxLayout>
    7. #include <QApplication>
    8.  
    9. #include "uiBoard.hpp"
    10. #include "uiSettings.hpp"
    11.  
    12. namespace ttt {
    13. class UIMain : public QWidget {
    14. Q_OBJECT
    15. private:
    16. UIBoard *uiboard_;
    17. UISettings *uisettings_;
    18. QHBoxLayout *mainLayout_;
    19. public:
    20. UIMain();
    21. };
    22. }
    23.  
    24. #endif /*UIMAIN_HPP_*/
    To copy to clipboard, switch view to plain text mode 

    uiMain.cpp
    Qt Code:
    1. #include "uiMain.hpp"
    2.  
    3. namespace ttt {
    4. UIMain::UIMain() :
    5. uiboard_( new UIBoard( 'X', true, this ) ),
    6. uisettings_( new UISettings( this ) ),
    7. mainLayout_( new QHBoxLayout( this ) ) {
    8.  
    9. uiboard_->setFixedSize( 300, 300 );
    10.  
    11. mainLayout_->addWidget( uiboard_ );
    12. mainLayout_->addWidget( uisettings_ );
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

    And finally, main.cpp
    Qt Code:
    1. #include <iostream>
    2.  
    3. #include <QApplication>
    4.  
    5. #include "uiMain.hpp"
    6.  
    7. int main( int argc, char *argv[] ) {
    8. QApplication app( argc, argv );
    9.  
    10. ttt::UIMain game;
    11. game.show();
    12.  
    13. return app.exec();
    14. }
    To copy to clipboard, switch view to plain text mode 

    I've attached images showing what I see when I start the program, and what I see after I manually enlarge the window.

    Any help would be greatly appreciated and I'd be happy to provide more information if it would help.
    Attached Images Attached Images
    Last edited by Jessehk; 2nd August 2007 at 16:55. 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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.