Results 1 to 4 of 4

Thread: QLayout alignment stretch

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

    Default QLayout alignment stretch

    In a QVBoxLayout :

    Is it possible both to align left/right and keep the stretching value of a given widget ?

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

    Default Re: QLayout alignment stretch

    Align what? The vertical layout aligns vertically, so no left-right here... And what do you mean by "stretching value"?

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

    Default Re: QLayout alignment stretch

    My bad, I was asking with QHBoxLayout in mind.

    Qt Code:
    1. mHBoxLayout->AddWidget(lineEdit, 10, Qt::AlignLeft);
    To copy to clipboard, switch view to plain text mode 

    In this case the "stretching value" is 10 and the widget is aligned on the left.
    Problem is since it's aligned to the left it wont stretch anymore.
    What if for example we want the widget to expand to a certain value without occupying the whole space of a layout.

    I'm not sure I'm making sense so let me give you an example :

    If I have a QTextEdit paragraph and I want to align the paragraph to the left by keeping the stretching at the same time. How am I suppose to achieve this ? in the layout ? in the QTextEdit widget ?

    Thanks.

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

    Default Re: QLayout alignment stretch

    The stretch factor only makes sense if you have more widgets in the layout. If you want to limit the expansion of a widget, just set its maximum size.

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.