[PyQt] question about QComboBox

Phillip Feldman phillip.m.feldman at gmail.com
Sat Apr 9 05:09:36 BST 2016


It looks as though one cannot apply a stylesheet to the delegate.  Even if
this were possible, it wouldn't help because there is only a single
delegate for the combobox, i.e., one would not be able to apply different
stylesheets to different combobox options.

On Thu, Apr 7, 2016 at 10:51 PM, Damon Lynch <damonlynch at gmail.com> wrote:

>
>
> On Fri, Apr 8, 2016 at 10:04 AM, Phillip Feldman <
> phillip.m.feldman at gmail.com> wrote:
>
>> My question was badly worded.  The PyQt4/PySide documentation for
>> QComboBox does show a setStyleSheet method for the top-level widget, and
>> this works just fine, but it looks as though there is nothing comparable
>> for the individual combobox options.
>>
>
> Setting a style sheet on a combobox can have surprising consequences for
> the visual appearance of the drop down list. In fact the drop down list can
> end up looking strikingly different to what you might expect -- and
> depending on your taste, not in a good way.
>
> The best solution I'm aware of is to use a delegate:
>
> comboboxDelegate = QStyledItemDelegate()
> combobox.setItemDelegate(comboboxDelegate)
>
> Applying a style sheet to the delegate might solve your problem too.
>
> Damon
>
> --
> http://www.damonlynch.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160408/0a0cc477/attachment.html>


More information about the PyQt mailing list