[Interest] About Qt StyleSheet

Berkay Elbir berkayelbir at gmail.com
Tue May 31 18:42:39 CEST 2016


Hi,

Actually, I think that problem is not related to any styles. If I write
this:

ui.newGroupNameLabel->setStyleSheet(" ");  also it does not have to be
QLabel. If I use QLineEdit, same problem occurs. Scenario is like that

If I call this code piece in constructor than everything is fine and you
can call setStyleSheet() function later there will be no problem. But If I
call this later for example slot of some button whatever, It occurs. It is
very strange, it affects whole widget after initialization.

Also, I know that If I use QPalette, problem does not occur but this is not
an option.


Cheers,

Berkay


On Tue, May 31, 2016 at 6:04 PM, Elvis Stansvik <elvstone at gmail.com> wrote:

> 2016-05-31 16:20 GMT+02:00 André Somers <andre at familiesomers.nl>:
>
>> Hi,
>>
>> What I _think_ happens is that you currently are using a style that does
>> not support style sheets. Only build in styles do, up to a point. If you
>> then apply a style sheet, Qt probably switches to a fall-back style that
>> _does_ support style sheets, but that has an effect on other widgets as
>> well as you noticed.
>>
>> I'd steer clear of using style sheets if you can. They generally end up
>> being more trouble than the're worth even though it seems like a simple
>> technique to use at first.
>>
> I'd also stay clear of style sheets. What you can try instead is modifying
> the foreground role of the palette with something like
>
>     QPalette palette = ui.newGroupNameLabel->palette();
>     palette.setColor(ui.newGroupNameLabel->foregroundRole(), Qt::black);
>     ui.newGroupNameLabel->setPalette(palette);
>
> Though it's not guaranteed to work on all platforms I think.
>
> You could also create your own custom label widget instead of using
> QLabel, if you really need to change the default look. I guess using <font
> color="#00000">...</font> is also an option.
>
> Hope that helps.
>
> Elvis
>
>> André
>>
>> Note: I did not check any of this in either docs or source code.
>>
>>
>> Op 31/05/2016 om 10:55 schreef Berkay Elbir:
>>
>> Hello All,
>>
>> I have a problem about Qt Stylesheets. I use this code piece, this is a
>> QLabel inside a QDialog.
>>
>> ui.newGroupNameLabel->setStyleSheet("QLabel { color : black; }");
>>
>> I also tried giving it a name usingQObject::setObjectName() and use an ID
>> Selector to refer to it. But it still occurs.
>>
>> It affects whole project. I mean that affecting other widgets. All the
>> expand symbols change to plus sign. This QLabel is unrelated to this
>> widget(below).
>> Did anyone face with this problem?
>>
>>
>> [image: Inline image 1]
>>
>>
>> [image: Inline image 2]
>>
>> Thanks in advance,
>>
>> Berkay
>>
>>
>>
>> _______________________________________________
>> Interest mailing listInterest at qt-project.orghttp://lists.qt-project.org/mailman/listinfo/interest
>>
>>
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>>
>
> _______________________________________________
> 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/20160531/3e1fa4e9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 807 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160531/3e1fa4e9/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 1018 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160531/3e1fa4e9/attachment-0001.png>


More information about the Interest mailing list