Solved Problem with Scollbar in QComboBox
-
Its me again. I have actually a Problem with my Scrollbar in a QComboBox. It looks really strange and i dont know why.
As you can see, the Scrollbar is halfed.
I just created the ComboBox like this and have done this.
texttype = new QComboBox(this); QString comboboxstale = "QComboBox " "{ " "padding: 4px; " "}"; texttype->setStyleSheet(comboboxstale); QFontDatabase fonts; texttype->addItems(fonts.families());
I dont have done more then that. I dont use the Designer, because its in an custom Widget. Anyone know how i can handle this?
-
Hi
When you apply a style sheet then other visual elements can be removed.
so its sometimes a all or nothing approach.
since you dont specify arrows etc, there are none. -
I commented the setStyleSheet out and the Problem is still there. I took a look at the link, but is there a Possibility to define Scollbar Sheets?
Update: i found a good StyleSheet now for that
QString comboboxstale = "QComboBox " "{" "padding: 4px;" "}" "QComboBox QAbstractItemView" "{" "margin: 0;" "padding: 0;" "}" "QComboBox QAbstractItemView QScrollBar:vertical" "{" "margin: 0;" "padding: 0;" "width: 15px;" "}";
-
@Fuel
Super.
I was slightly wrong.
Adding padding did not remove the scrollbars but added padding to them too :)
If you removed texttype->setStyleSheet and it still shows , its because you added padding/a stylesheet to the parent.Stylesheets is cascading , meaning it affects to all children too.
So its best to Add to the application so all is affected or to a window if only needed there.
Applying a style sheet to each widget often ends up a huge mess :)
-
Ah ok. Much thanks. Slowly i understand how its all working.