oclero / qlementine

⚠️🏗️ [WORK IN PROGRESS] 🍊Modern QStyle for desktop Qt6 applications.
https://oclero.github.io/qlementine/
MIT License
72 stars 16 forks source link

Provide Efficient Method to Dynamically Change Control Colors while using qlementinestyle #49

Open pinojojo opened 9 months ago

pinojojo commented 9 months ago

Hi, oclero,

I'm really impressed with this repository, particularly the animations. However, I've encountered a challenge when using the library. There doesn't seem to be a straightforward method for changing the colors of controls, such as the foreground font or background colors. This feature is particularly necessary when differentiating individual buttons among a group, where some buttons require color highlighting for emphasis.

My attempts to use the widget's palette and stylesheet, which are generally considered the standard approach, were unsuccessful. Further investigation into the source code revealed that the buttonBackgroundColor is governed by the theme in qlementinestyle. As I understand it, this theme isn't intended for frequent dynamic updates during the entire application session.

While I could follow the example in the source code and create a qproxystyle to modify the colors, ensuring that the corner radius remains consistent with qlementine, I find this solution rather cumbersome. Is there a simpler method to alter specific colors within the library?

oclero commented 9 months ago

Qt's CSS is not supported by choice in Qlementine. When you define CSS on a QWidget, its style becomes QStylesheetStyle, which is painfully slow, buggy (it can't even draw clean rounded corners...) and complex, and can't do animations. I want to avoid that at all costs. This is the raison d'être of Qlementine.

Currently, the theming system is minimal on purpose. The goal is to avoid having a 3000-line CSS file as commonly seen in entreprise Qt projects. Also, a corollary is that it forces developers to use a simple design system instead of making lots of special cases and mixing style code and UI code.

Also, currently, proxy styles are not supported yet, since it adds a whole layer of complexity and could create many bugs in the developer's proxy style code. I would like to add this feature someday, though.

Here are 2 alternative solutions to your problem: