Results 1 to 5 of 5

Thread: Quick spacing question

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2007
    Posts
    91
    Thanks
    21
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Unhappy Quick spacing question

    I just don't get the spacing options with Qt.

    I have a widget and I want to put three buttons at the bottom of the widget. Now, however, the three buttons are taking up all the space along the bottom of the window. I've tried adding spacing, via addSpacing(1) both before and after the buttons, but they still take the full space. I've tried setting the align option on the addWidget() to Qt:AlignCenter to the center one and AlignLeft to the left one and alignRight to the right one. I've tried setting the stretch to -1, but nothing works.

    What's the trick?
    -BRC

  2. #2
    Join Date
    Jan 2007
    Posts
    91
    Thanks
    21
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Quick spacing question

    Maybe I've figured it out - I'm now using addStretch on both sides.


    Right?

  3. #3
    Join Date
    Feb 2007
    Posts
    73
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Quick spacing question

    An alternative to that is to put the buttons in a QHBoxLayout or QGridLayout, then add QSpacerItem instances to each side using the ::addItem method on the layout.

    HTH,
    Susan

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

    Default Re: Quick spacing question

    Quote Originally Posted by bruccutler View Post
    Maybe I've figured it out - I'm now using addStretch on both sides.

    Right?
    Right.

    You could have also changed size policies of the buttons (for example to "fixed"), so that they wouldn't expand to fill all the space available.

  5. #5
    Join Date
    Jan 2007
    Posts
    91
    Thanks
    21
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Talking Re: Quick spacing question

    Quote Originally Posted by wysota View Post
    Right. But the real problem is that you didn't set size policies properly.
    Suggestion? How do I set the size policies? I'm coding these by hand. I'll go look them up, but maybe you can asisst?
    - BRC

Similar Threads

  1. Quick question regarding abstract classes and DLLs
    By durbrak in forum Qt Programming
    Replies: 1
    Last Post: 8th February 2007, 21:32
  2. quick question on model/view programming
    By locus in forum Qt Programming
    Replies: 1
    Last Post: 2nd February 2007, 10:04
  3. Question regarding how to paint after zoom.
    By JonathanForQT4 in forum Qt Programming
    Replies: 2
    Last Post: 26th January 2007, 15:34
  4. QVector QVarLengthArray speed question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 22nd January 2007, 09:28
  5. QThread exit()/quit() question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2006, 14:38

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
  •  
Qt is a trademark of The Qt Company.