Results 1 to 3 of 3

Thread: QSpacerItem doesn't respect the minimum width of the qcombobox

  1. #1
    Join Date
    Oct 2015
    Posts
    17
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default QSpacerItem doesn't respect the minimum width of the qcombobox

    Hi everyone.

    I have the next problem. In runtime I create a QWidget with a QHBoxLayout layout and from the left to the right, I create a QLabel, a QSpacerItem, a QComboBox and a QPushButton. The idea is putting the label on the left and all the rest to the right. I put a minimum width to the combo but the spaceritem doesn't respect it doing it smaller than I want. Why?

    The QSpacerItem:
    Qt Code:
    1. auto headerSpacer = new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
    To copy to clipboard, switch view to plain text mode 
    The minimum width of the combo:
    Qt Code:
    1. comboDevices->setMinimumWidth(500);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSpacerItem doesn't respect the minimum width of the qcombobox

    Have you tried with a non-zero size?

    Btw, if you are doing that in code, then calling QBoxLayout::addStretch() would be less code.

    Cheers,
    _

  3. #3
    Join Date
    Oct 2015
    Posts
    17
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: QSpacerItem doesn't respect the minimum width of the qcombobox

    It as my fault. Ten lines of code below I had
    Qt Code:
    1. comboDevices->setMinimumWidth(175);
    To copy to clipboard, switch view to plain text mode 


    Anyway thanks for the addStretch function, I didn't know it.

Similar Threads

  1. Replies: 0
    Last Post: 4th January 2013, 04:59
  2. qmake doesn't respect QMAKESPEC variable
    By piotr.dobrogost in forum Installation and Deployment
    Replies: 5
    Last Post: 19th July 2009, 22:08
  3. Replies: 0
    Last Post: 13th February 2009, 15:17
  4. Forcing a minimum list widget width
    By MrGarbage in forum Qt Tools
    Replies: 1
    Last Post: 14th July 2007, 17:16
  5. QTable column stretchable with minimum Width
    By sunil.thaha in forum Qt Programming
    Replies: 0
    Last Post: 24th April 2006, 13:17

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.