Results 1 to 2 of 2

Thread: QSpacerItem constructor arguments

  1. #1
    Join Date
    Feb 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QSpacerItem constructor arguments

    Hi! I'm not sure what values to use in the following situation:

    Qt Code:
    1. verticalSpacer = new QSpacerItem(/*???*/); // Not sure what to make of this
    2.  
    3. verticalLayout_2 = new QVBoxLayout();
    4. verticalLayout_2->addWidget(advancedButton);
    5. verticalLayout_2->addWidget(addButton);
    6. verticalLayout_2->addWidget(removeButton);
    7. verticalLayout_2->addSpacerItem(verticalSpacer);
    To copy to clipboard, switch view to plain text mode 

    If I simply add two integers for w and h it works but not as I want it; I want it to push the 3 buttons completely together regardless of the window size

    The description on the online documentation confuses me
    Qt Code:
    1. QSpacerItem::QSpacerItem ( int w, int h, QSizePolicy::SizeType hData = QSizePolicy::Minimum, QSizePolicy::SizeType vData = QSizePolicy::Minimum )
    2.  
    3. Constructs a spacer item with preferred width w, preferred height h, horizontal size policy hData and vertical size policy vData.
    4.  
    5. The default values provide a gap that is able to stretch if nothing else wants the space.
    To copy to clipboard, switch view to plain text mode 

    How do I make verticalSpacer take up all available space in the vertical direction?

    Thanks in advance
    Last edited by Defeatist; 10th February 2010 at 18:25.

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSpacerItem constructor arguments

    use

    Qt Code:
    1. QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding);
    To copy to clipboard, switch view to plain text mode 

    w and h parameters are preferred dimension. Using QSizePolicy::Expanding for vertical size policy you can obtain what you want.
    A camel can go 14 days without drink,
    I can't!!!

Similar Threads

  1. How do I add a QSpacerItem to a toolbar?
    By di_zou in forum Newbie
    Replies: 5
    Last Post: 23rd June 2021, 02:12
  2. C++ function arguments doubt?
    By rajeshs in forum General Programming
    Replies: 2
    Last Post: 26th September 2008, 12:14
  3. QVector arguments
    By phillip_Qt in forum Qt Programming
    Replies: 2
    Last Post: 4th December 2007, 10:47
  4. QSpaceritem problem with crashing
    By moowy in forum Qt Programming
    Replies: 2
    Last Post: 3rd November 2006, 19:52

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.