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. Setting QList properties in qss files
Forum Update on Monday, May 27th 2025

Setting QList properties in qss files

Scheduled Pinned Locked Moved Unsolved General and Desktop
qssqpropertyqlist
5 Posts 3 Posters 2.3k Views
  • 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.
  • mongrelmacM Offline
    mongrelmacM Offline
    mongrelmac
    wrote on last edited by mongrelmac
    #1

    I have a widget with custom Q_PROPERTYs defined that I'd like to modify in a .qss file. Most are pretty simple/straightforward (doubles or QColors), and can be modified virtually identically to this example. But I'd like to implement one property as a list of QColors, and modify it in the .qss file. Defining the Q_PROPERTY and registering it with the meta-object system isn't a problem, but I haven't found a way to set the property in the stylesheet. Has anyone else wrestled with this problem?

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

      Hi and welcome to devnet,

      I haven't tried that yet but I'm curious about what you already tried.

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

      mongrelmacM 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        I haven't tried that yet but I'm curious about what you already tried.

        mongrelmacM Offline
        mongrelmacM Offline
        mongrelmac
        wrote on last edited by
        #3

        @SGaist Thanks!

        I can successfully set the list property using QObject::setProperty(...) but can't seem to find a way to set the same property from the .qss file. I would imagine it has something to do with how the stylesheet is parsed?

        raven-worxR 1 Reply Last reply
        0
        • mongrelmacM mongrelmac

          @SGaist Thanks!

          I can successfully set the list property using QObject::setProperty(...) but can't seem to find a way to set the same property from the .qss file. I would imagine it has something to do with how the stylesheet is parsed?

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @mongrelmac said:

          I would imagine it has something to do with how the stylesheet is parsed?

          exactly. Qt stylesheets don't support parsing of list types.
          The only thing you can do is, to declare the property as string and parse the string to your list in the setter of the property.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • mongrelmacM Offline
            mongrelmacM Offline
            mongrelmac
            wrote on last edited by
            #5

            I see. Thanks @raven-worx @SGaist!

            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