Results 1 to 7 of 7

Thread: [CSS/QCombobox] setting min-height for drop down list

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [CSS/QCombobox] setting min-height for drop down list

    I have exactly the same problem. I tried a lot of different styles to apply, but none of them worked. In my opinion, the following CSS should work, but it doesn't:
    Qt Code:
    1. {
    2. padding-top: 10px;
    3. padding-bottom: 10px;
    4. }
    To copy to clipboard, switch view to plain text mode 
    I tried also the tip from another thread (http://www.qtcentre.org/forum/f-qt-p...box-12025.html) to add the QApplication::globalStrut. This works for all Widgets, except AbstractItemView of the QComboBox.

    I'm at the moment with Qt 4.3.2, and will try it today with Qt 4.4.

    One solution would be to implement a custom model. But it would be so nice if I don't have to implement a custom model.

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

    Default Re: [CSS/QCombobox] setting min-height for drop down list

    Solution is (at least for Qt 4.6.0):

    Qt Code:
    1. setStyleSheet("QComboBox { min-height: 40px; min-width: 60px; }"
    2. "QComboBox QAbstractItemView::item { min-height: 40px; min-width: 60px; }");
    3. QComboBox *combo = new QComboBox(this);
    4. combo->setView(new QListView());
    To copy to clipboard, switch view to plain text mode 
    if you omit the last line (setView call), the style sheet wont be applied to the default combobox item view.

  3. #3
    Join Date
    Nov 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: [CSS/QCombobox] setting min-height for drop down list

    Thanks very much for this solution.
    Works too with 4.7.2, seems to still be the same bug.

  4. #4
    Join Date
    Jul 2012
    Posts
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanks
    2

    Default Re: [CSS/QCombobox] setting min-height for drop down list

    It works!But I wonder if every QComboBox uses "combo->setView(new QListView());",Could it cause memory leak?

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: [CSS/QCombobox] setting min-height for drop down list

    Quote Originally Posted by æž—å©· View Post
    It works!But I wonder if every QComboBox uses "combo->setView(new QListView());",Could it cause memory leak?
    No, it couldn't.
    The doc says:
    Sets the view to be used in the combobox popup to the given itemView. The combobox takes ownership of the view.
    Read about QComboBox::setView carefully.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  6. #6
    Join Date
    Aug 2013
    Posts
    27
    Thanks
    3

    Default Re: [CSS/QCombobox] setting min-height for drop down list

    Quote Originally Posted by MarkRus View Post
    Solution is (at least for Qt 4.6.0):

    Qt Code:
    1. setStyleSheet("QComboBox { min-height: 40px; min-width: 60px; }"
    2. "QComboBox QAbstractItemView::item { min-height: 40px; min-width: 60px; }");
    3. QComboBox *combo = new QComboBox(this);
    4. combo->setView(new QListView());
    To copy to clipboard, switch view to plain text mode 
    if you omit the last line (setView call), the style sheet wont be applied to the default combobox item view.
    if you omit the last line (setView call), the style sheet wont be applied to the default combobox item view.
    It should be higtligeted!.

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.