Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Detect arbitrary custom attributes from application QSS style in MyWidget::paintEvent?

Detect arbitrary custom attributes from application QSS style in MyWidget::paintEvent?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 881 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on last edited by
    #1

    So I have a custom widget that I want to style. I use an application-wide style for styling everything else, but my widget has this specific thing that it paints, and it would be very neat if it could retrieve its color from QSS, e. g.:

    MyWidget { customThingColor: red }
    

    Is it doable? Certainly, it's not the only way to pass a parameter to a widget, but it would be most neat if I could put ALL the styling code in a single app-wide QSS string.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You can use designable Q_PROPERTIES for that. See here

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      V 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        You can use designable Q_PROPERTIES for that. See here

        V Offline
        V Offline
        Violet Giraffe
        wrote on last edited by
        #3

        @SGaist, awesome, that works! Thanks a lot. Sorry I couldn't find it in the docs.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved