+ Reply to Thread
Results 1 to 6 of 6

Thread: QComboBox padding bug

  1. #1
    Join Date
    Mar 2018
    Posts
    3
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Exclamation QComboBox padding bug

    Hello.

    I walking into a strange behaviour of QComboBox.

    When padding-top is applied to QComboBox its popup gains equal value top and bottom paddings somehow.
    Any other padding set for the ComboBox does not affect paddings inside its popup.
    You can see them on attached image.

    I haven't found any solution to remove those paddings from popup.

    The question is how to removed them or if it is a bug is there any known workaround?

    Here is minimal example to reproduce this.

    OS Ubuntu 16.03, Qt 5.5.1

    Qt Code:
    1. #include <QApplication>
    2. #include <QComboBox>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7.  
    8. w.resize(200, 200);
    9. QComboBox cb(&w);
    10.  
    11. cb.setFixedSize(120, 60);
    12. cb.addItems({"1", "2", "3", "4", "5"});
    13. cb.setStyleSheet(R"(
    14. QComboBox {
    15. padding-top: 20;
    16. }
    17. )");
    18.  
    19. w.show();
    20.  
    21. return app.exec();
    22. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    3,659
    Thanks
    212
    Thanked 560 Times in 550 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: QComboBox padding bug

    Maybe the behavior you are seeing is because you are creating your combobox and putting it directly into the QWidget parent without using any layout or geometry. Try making a proper compound widget with a layout and using "new" to create the combobox on the heap instead of on the stack.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Mar 2018
    Posts
    3
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox padding bug

    Quote Originally Posted by d_stranz View Post
    Maybe the behavior you are seeing is because you are creating your combobox and putting it directly into the QWidget parent without using any layout or geometry. Try making a proper compound widget with a layout and using "new" to create the combobox on the heap instead of on the stack.
    Layouting widget or especially the way of creating them cannot influence this behaviour. O_o
    I am almost sure that it is a bug in the Qt.
    Also I found out that border-radius property in this case working bad as well.

    So the question is how to workaround indeed.

  4. #4
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    393
    Thanked 47 Times in 43 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox padding bug

    This looks like a style problem. It works perfectly when the style draws the drop-down menu below the combobox. As soon as it draws it on top (e.g. gtk2, fusion), the additional space is added. I would suggest to open a qt bug report.

  5. #5
    Join Date
    Mar 2018
    Posts
    3
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox padding bug

    Quote Originally Posted by ChristianEhrlicher View Post
    I would suggest to open a qt bug report.
    Where to do that?

  6. #6
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    393
    Thanked 47 Times in 43 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox padding bug


+ Reply to Thread

Similar Threads

  1. Replies: 2
    Last Post: 9th February 2017, 22:36
  2. QwtText background padding
    By Maximus2 in forum Qwt
    Replies: 7
    Last Post: 8th January 2015, 07:20
  3. Qwt: curve with padding
    By alperyazir in forum Qwt
    Replies: 1
    Last Post: 11th November 2014, 10:19
  4. QLineEdit padding
    By bunjee in forum Qt Programming
    Replies: 0
    Last Post: 17th September 2008, 22:43
  5. QString:: Padding Zeros?
    By Harvey West in forum Qt Programming
    Replies: 2
    Last Post: 27th February 2007, 18:25

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