QComboBox StyleSheet bug



  • Just so no-one else chases their tail for days..

    I was trying to create a custom look for a ComboBox.

    I used the CSS editor in Creator to develop it. Used the Creator Tool - Form Editor - Preview option to show the edited results. Worked fine and as expected in Creator.

    Not so much in the "real" app. I used the edited CSS to load a global style sheet via a call to qApp->setStyleSheet() . This generated weird results..usually a single ComboBox on a form with the correct look and all the rest with a buggered up drop-down arrow. I'm not using a custom graphic for the drop-down arrow..just a generic definition.

    I finally traced the problem to the ComboBox->clear() method. The "clear()" has no negative effects if you do not load a custom CSS for QComboBox. If you do use a custom CSS, the clear() method, evidently also "clears" part of the CSS..not all..just part..the part associated with drop-down arrow.

    According to documentation the clear() method "Clears the combobox, removing all items." It makes no mention of also messing with the CSS.

    My app loads ComboBoxes dynamically from a database, so it's necessary to call "clear()" prior to loading a new item list.

    I solved the "buggered up drop-down arrow" problem by reloading the CSS for the ComboBox each time it was "cleared" and a new item list was loaded. Shouldn't have to do that, but that fixes the issue.

    This seems like a bug to me. If it's not a bug, then the documentation should be changed to reflect what is actually happening to the ComboBox when "clear()" is called. IE what is REALLY cleared...because it's not just the items in the list.



  • Hi! Couldn't find that bug in the database, maybe you want to report it: https://bugreports.qt.io


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.