Qt stylesheets : per-user default qss capability? (was Re: how to use kdialog --font ?)

Kevin Krammer krammer at kde.org
Wed Oct 28 09:46:00 GMT 2015


On Tuesday, 2015-10-27, 17:20:47, Stephen Dowdy wrote:
> On Tue, Oct 27, 2015 at 1:24 PM, Kevin Krammer <krammer at kde.org> wrote:
> > CTRL+SHIFT+Left Click on any part in the observed application (in your
> > case
> > kdialog), should jump to that object in Gammaray's tree.
> > 
> > You can then also adjust properties at runtime, e.g. the stylesheet
> > property.
> > 
> > See http://doc.qt.io/qt-4.8/stylesheet-examples.html for small example
> > stylesheets.
> 
> ​Kevin,​
> 
> Great stuff, exactly what i was looking for.
> 
> ​'strace' reveals no default search for .qss files (at least in
> 'kdialog').  ​
> ​So, is there a way to create a user stylesheet that all Qt apps will
> reference?   One that can be obtained via Environment Variable or perhaps
> an entry (or several) in Trolltech.conf?

I don't know. Doesn't mean it doesn't exist, but so far I hadn't even known 
that one could pass it on the commandline.

> If so, one could create a "userStyle.qss" that had stuff like:​
> 
>> KDialog > QWidget > QLabel {
>     font-family: monospace;
>     font-size: 16;
>     background-color: rgb(40,40,40);
>     color:rgb(220,220,220);
> }
> 
> ​which, theoretically should only apply to KDialog (executable, or i think
> there's an API?)

The matching rules do not check for the program name as far as I know, only 
classes and properties of elements.

> (unfortunately, the labels in KDialog don't have class/id AFAICT, so you
> hit all of them)

They might have different object names. Check their "objectName" properties in 
Gammaray.

> I suppose this is getting low-level enough that reliance from one release
> to another might get "iffy".

The QSS stuff is pretty stable, I don't think there were even any changes 
between Qt4 and Qt5.

Cheers,
Kevin
-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde/attachments/20151028/502b3bf1/attachment.sig>
-------------- next part --------------
___________________________________________________
This message is from the kde mailing list.
Account management:  https://mail.kde.org/mailman/listinfo/kde.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.html.


More information about the kde mailing list