Results 1 to 4 of 4

Thread: Problem with layout

  1. #1
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problem with layout

    Hi,
    I trying to layout my widgets but it doesn't work.

    I would create 2 widget with a fixed hight and an expanding width but it doesn't work.
    I create them so:

    Qt Code:
    1. CentralWidget::CentralWidget( QWidget* parent /* = 0 */ )
    2. : QWidget(parent),
    3. mp_vBox( 0 ),
    4. m_pWaveU( 0 ),
    5. m_pWaveD( 0 )
    6. {
    7. /* vertical LAYOUT */
    8. mp_vBox = new QVBoxLayout( this );
    9.  
    10. /* 2 WAVEFORM DISPLAY */
    11. m_pWaveU = new WaveDisplay( this );
    12. m_pWaveU->setGeometry(0, 0,200,150); // I would for this a fixed geometry in height
    13. m_pWaveU->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Minimum );//I WOULD THIS WITH A FIXED HEIGHT AND THAT IT CAN EXPAND HORIZONTALY
    14.  
    15. m_pWaveD = new WaveDisplay( this );
    16. m_pWaveD->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored );
    17. mp_vBox->addWidget( m_pWaveU );
    18. mp_vBox->addSpacing( 15 );
    19. mp_vBox->addWidget( m_pWaveD );
    20. setLayout(mp_vBox);
    21. }
    To copy to clipboard, switch view to plain text mode 

    Where my code is wrong?
    Best Regards
    Franco Amato

  2. #2
    Join Date
    Jul 2009
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with layout

    enum QSizePolicy::Policy

    This enum describes the various per-dimension sizing types used when constructing a QSizePolicy.

    Constant Value Description
    QSizePolicy::Fixed 0 The QWidget::sizeHint() is the only acceptable alternative, so the widget can never grow or shrink (e.g. the vertical direction of a push button).
    QSizePolicy::Minimum GrowFlag The sizeHint() is minimal, and sufficient. The widget can be expanded, but there is no advantage to it being larger (e.g. the horizontal direction of a push button). It cannot be smaller than the size provided by sizeHint().
    QSizePolicy::Maximum ShrinkFlag The sizeHint() is a maximum. The widget can be shrunk any amount without detriment if other widgets need the space (e.g. a separator line). It cannot be larger than the size provided by sizeHint().
    QSizePolicy::Preferred GrowFlag | ShrinkFlag The sizeHint() is best, but the widget can be shrunk and still be useful. The widget can be expanded, but there is no advantage to it being larger than sizeHint() (the default QWidget policy).
    QSizePolicy::Expanding GrowFlag | ShrinkFlag | ExpandFlag The sizeHint() is a sensible size, but the widget can be shrunk and still be useful. The widget can make use of extra space, so it should get as much space as possible (e.g. the horizontal direction of a horizontal slider).
    QSizePolicy::MinimumExpanding GrowFlag | ExpandFlag The sizeHint() is minimal, and sufficient. The widget can make use of extra space, so it should get as much space as possible (e.g. the horizontal direction of a horizontal slider).
    QSizePolicy::Ignored ShrinkFlag | GrowFlag | IgnoreFlag The sizeHint() is ignored. The widget will get as much space as possible.
    See also PolicyFlag, setHorizontalPolicy(), and setVerticalPolicy().

  3. #3
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with layout

    Quote Originally Posted by method View Post
    enum QSizePolicy::Policy

    This enum describes the various per-dimension sizing types used when constructing a QSizePolicy.

    Constant Value Description
    QSizePolicy::Fixed 0 The QWidget::sizeHint() is the only acceptable alternative, so the widget can never grow or shrink (e.g. the vertical direction of a push button).
    QSizePolicy::Minimum GrowFlag The sizeHint() is minimal, and sufficient. The widget can be expanded, but there is no advantage to it being larger (e.g. the horizontal direction of a push button). It cannot be smaller than the size provided by sizeHint().
    QSizePolicy::Maximum ShrinkFlag The sizeHint() is a maximum. The widget can be shrunk any amount without detriment if other widgets need the space (e.g. a separator line). It cannot be larger than the size provided by sizeHint().
    QSizePolicy::Preferred GrowFlag | ShrinkFlag The sizeHint() is best, but the widget can be shrunk and still be useful. The widget can be expanded, but there is no advantage to it being larger than sizeHint() (the default QWidget policy).
    QSizePolicy::Expanding GrowFlag | ShrinkFlag | ExpandFlag The sizeHint() is a sensible size, but the widget can be shrunk and still be useful. The widget can make use of extra space, so it should get as much space as possible (e.g. the horizontal direction of a horizontal slider).
    QSizePolicy::MinimumExpanding GrowFlag | ExpandFlag The sizeHint() is minimal, and sufficient. The widget can make use of extra space, so it should get as much space as possible (e.g. the horizontal direction of a horizontal slider).
    QSizePolicy::Ignored ShrinkFlag | GrowFlag | IgnoreFlag The sizeHint() is ignored. The widget will get as much space as possible.
    See also PolicyFlag, setHorizontalPolicy(), and setVerticalPolicy().
    Hi I changed the previous code so
    Qt Code:
    1. CentralWidget::CentralWidget( QWidget* parent /* = 0 */ )
    2. : QWidget(parent),
    3. mp_vBox( 0 ),
    4. m_pWaveU( 0 ),
    5. m_pWaveD( 0 )
    6. {
    7. /* vertical layout */
    8. mp_vBox = new QVBoxLayout( this );
    9.  
    10. /* 2 wavwform display */
    11. m_pWaveU = new WaveDisplay( this );
    12. m_pWaveU->setGeometry(10, 10, 200, 150);
    13. m_pWaveU->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Fixed );
    14.  
    15. m_pWaveD = new WaveDisplay( this );
    16. m_pWaveD->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    17. mp_vBox->addWidget( m_pWaveU );
    18. mp_vBox->addSpacing( 15 );
    19. mp_vBox->addWidget( m_pWaveD );
    20. setLayout(mp_vBox);
    21. }
    To copy to clipboard, switch view to plain text mode 
    But now the m_pWaveU is missing, I can not see it in the form.
    Where I'm wrong?
    Thank you in advance.
    Franco Amato

  4. #4
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with layout

    And with this last code both widget are missing, I can not see nothing
    Qt Code:
    1. CentralWidget::CentralWidget( QWidget* parent /* = 0 */ )
    2. : QWidget(parent),
    3. mp_vBox( 0 ),
    4. m_pWaveU( 0 ),
    5. m_pWaveD( 0 )
    6. {
    7. /* vertical layout */
    8. mp_vBox = new QVBoxLayout( this );
    9.  
    10. /* 2 wavwform display */
    11. m_pWaveU = new WaveDisplay( this );
    12. m_pWaveU->setGeometry(10, 10, 200, 150);
    13. m_pWaveU->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
    14.  
    15. m_pWaveD = new WaveDisplay( this );
    16. m_pWaveD->setGeometry( 10, 160, 200,150);
    17. m_pWaveD->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
    18. mp_vBox->addWidget( m_pWaveU );
    19. mp_vBox->addSpacing( 15 );
    20. mp_vBox->addWidget( m_pWaveD );
    21. setLayout(mp_vBox);
    22. }
    To copy to clipboard, switch view to plain text mode 
    Franco Amato

Similar Threads

  1. Hide and Show problem in master layout
    By QPlace in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2009, 16:04
  2. layout direction issues with QGraphicsScene
    By sanjayshelke in forum Qt Programming
    Replies: 2
    Last Post: 16th June 2009, 23:23
  3. Replies: 2
    Last Post: 9th July 2008, 22:28
  4. QStackedWidget layout problem
    By Banjo in forum Qt Programming
    Replies: 9
    Last Post: 15th May 2008, 00:15
  5. Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 4
    Last Post: 19th April 2006, 11:08

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.