[Interest] Hide icon in a QComboBox associated with a Model
Scott Aron Bloom
scott.bloom at onshorecs.com
Sat Aug 24 04:42:00 CEST 2013
If you are on Qt 5 yes :)
From: interest-bounces+scott.bloom=onshorecs.com at qt-project.org [mailto:interest-bounces+scott.bloom=onshorecs.com at qt-project.org] On Behalf Of André Somers
Sent: Friday, August 23, 2013 9:16 AM
To: interest at qt-project.org
Subject: Re: [Interest] Hide icon in a QComboBox associated with a Model
Op 23-8-2013 17:58, Scott Aron Bloom schreef:
Create a proxy model (derive from QSortFilterProxyModel if you have never created one and don't have any sorting or filtering turned on) and override the data method, returning QVariant for the icon role.
Then set the source model for the proxy model, to your original, and the model for the combobox to the proxy model.
If you're not going to do any sorting or filtering with the proxy, I would advise to use QIdentityProxyModel as your base class instead of QSortFilterProxyModel.
From: interest-bounces+scott.bloom=onshorecs.com at qt-project.org<mailto:interest-bounces+scott.bloom=onshorecs.com at qt-project.org> [mailto:interest-bounces+scott.bloom=onshorecs.com at qt-project.org] On Behalf Of Etienne Sandré-Chardonnal
Sent: Friday, August 23, 2013 8:02 AM
To: interest at qt-project.org<mailto:interest at qt-project.org>
Subject: [Interest] Hide icon in a QComboBox associated with a Model
I have a model representing the objects loaded in my app. This model provides icons for the IconRole, so that the object list docking widget looks nice.
In another control, I want to link a QComboBox with the model. This works very well as the QComboBox updates itself with the model updates with no additionnal code.
I want to hide the icons in the QComboBox. I can find no functions for disabling them, setting the size to 0 is a workaround, but a space remains before the text, which looks not so nice (maybe some non-zero layout spacing which remains, even if the icon widget is zero-sized)
Is there any better and simple option? Maybe adding a hideIcons() feature in QComboBox would help.
Interest mailing list
Interest at qt-project.org<mailto:Interest at qt-project.org>
You like Qt?
I am looking for collegues to join me at i-Optics!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest