PDA

View Full Version : QComboBox padding bug



.andrew
12th March 2018, 18:09
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


#include <QApplication>
#include <QComboBox>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QWidget w;
w.resize(200, 200);
QComboBox cb(&w);

cb.setFixedSize(120, 60);
cb.addItems({"1", "2", "3", "4", "5"});
cb.setStyleSheet(R"(
QComboBox {
padding-top: 20;
}
)");

w.show();

return app.exec();
}

d_stranz
13th March 2018, 04:17
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.

.andrew
13th March 2018, 11:01
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.

ChristianEhrlicher
13th March 2018, 18:05
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.

.andrew
15th March 2018, 17:30
I would suggest to open a qt bug report.
Where to do that?

ChristianEhrlicher
15th March 2018, 17:35
https://bugreports.qt.io