[Interest] QSS/CSS styling a border on a combo removes styles from dropdown control

Philipp Kursawe phil.kursawe at gmail.com
Wed Nov 27 15:14:33 CET 2013


Thanks!
I usually do not like to write custom code for such things. I think this is
a bug on side of the combox implementation to get rid of any native
rendering when you set the border style. It falls back to a non-standard
style (looks like Win 3.1).



On Wed, Nov 27, 2013 at 1:15 PM, Nurmi J-P <jpnurmi at digia.com> wrote:

>
> On 27 Nov 2013, at 12:46, Philipp Kursawe <phil.kursawe at gmail.com> wrote:
>
> > That's what I already did. I am using the second variant.
> >
> >
> > On Wed, Nov 27, 2013 at 12:07 PM, Nurmi J-P <jpnurmi at digia.com> wrote:
> >
> > On 27 Nov 2013, at 11:10, Philipp Kursawe <phil.kursawe at gmail.com>
> wrote:
> >
> > > I wonder if that is a bug:
> > > If I style a QComboBox's border with a "2px solid red" it looses its
> style on the dropdown arrow, which happened to be flat styled (on Windows)
> and then appears in 3D beveled style like old Win95. No more styles have
> been applied to this combo via css.
> > >
> > > Whats going on here?
> > >
> > > Is there a way to bring back the "default" style (reset a style) on
> the dropdown sub-control?
> > >
> >
> > Try using selectors [*] to avoid applying the border to all children of
> QComboBox.
> >
> > These two have very different results:
> >
> >     comboBox1->setStyleSheet("border: 2px solid red;”);
> >     comboBox2->setStyleSheet("QComboBox { border: 2px solid red; }”);
> >
> > [*]
> http://qt-project.org/doc/qt-5.1/qtwidgets/stylesheet-syntax.html#selector-types
>
> Oh, I missed the “arrow” part. I thought the drop down was getting
> undesired style changes, which you can avoid by using selectors. Anyway,
> I’m afraid there’s no way to keep the native arrow whilst applying
> _stylesheets_ to the other parts of the combo box. Once you apply a
> stylesheet, you lose the native style.
>
> What you could do instead is to customize individual
> primitives/subcontrols (perhaps SC_ComboBoxFrame?) using a proxy style.
> That way you can keep the native style for the other primitives/subcontrols
> (eg. SC_ComboBoxArrow).
>
> http://doc-snapshot.qt-project.org/qt5-release/qproxystyle.html
>
> --
> J-P Nurmi
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131127/60991d4b/attachment.html>


More information about the Interest mailing list