Results 1 to 3 of 3

Thread: Popup of QComboBox wider than combobox?

  1. #1
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question Popup of QComboBox wider than combobox?

    Hi, I have a combobox with a fixed size (it is inside a QTableWidget cell) and enough entries to need a scrollbar.
    I would like the popup of the combobox to be wider than the combobox itself (see attached image for a rough example). Is this possible?
    I tried
    - QComboBox::setSizeAdjustPolicy (QComboBox::AdjustToContents), but this also changes the width of the combobox and not only the popup's width
    - QAbstractItemView::setTextElideMode (Qt::ElideNone) on the view() of the combobox. Now the text of the entries isn't elided anymore but the size of the popup does not change, so the scrollbar is above part of the text
    - QWidget::setGeometry() on the view(). It looks like this resized something internally, because the scrollbar disappeared, but the popup itself is still the same size, so I cannot read the whole text of the entries
    - an ItemDelegate on the view() that reimplements sizeHint(), but this had no effect at all.

    I'm out of ideas now. Is this possible at all? Any further suggestions?

    Ginsengelf

    edit: I could not set elideMode in designer, so just imagine the image without the elided text in the popup.
    Attached Images Attached Images
    Last edited by Ginsengelf; 20th October 2016 at 11:35. Reason: updated contents

  2. #2
    Join Date
    Mar 2014
    Posts
    23
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android

    Default Re: Popup of QComboBox wider than combobox?

    You can set the minWidth property of the combobox's view. One way to do this is with a stylesheet. Another way is to calculate the largest text width of all items (utilizing font metrics) and then set the width of the view accordingly. The latter needs to be done as soon as an item is added/removed.

  3. The following user says thank you to Killian for this useful post:

    Ginsengelf (21st October 2016)

  4. #3
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Popup of QComboBox wider than combobox?

    Thanks, this works.

    Ginsengelf

Similar Threads

  1. Replies: 3
    Last Post: 2nd November 2015, 17:33
  2. Replies: 0
    Last Post: 18th August 2013, 19:07
  3. QComboBox popup
    By berchio in forum Qt Programming
    Replies: 0
    Last Post: 25th October 2012, 21:05
  4. QComboBox Popup position
    By alitoh in forum Qt Programming
    Replies: 1
    Last Post: 25th November 2011, 11:16
  5. QComboBox popup
    By aekilic in forum Qt Programming
    Replies: 9
    Last Post: 6th January 2009, 11:24

Tags for this Thread

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.