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

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.
  • M Offline
    M Offline
    mongrelmac
    wrote on 7 Jul 2016, 21:26 last edited by mongrelmac 7 Jul 2016, 22:22
    #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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 7 Jul 2016, 22:08 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

      M 1 Reply Last reply 7 Jul 2016, 22:24
      0
      • S SGaist
        7 Jul 2016, 22:08

        Hi and welcome to devnet,

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

        M Offline
        M Offline
        mongrelmac
        wrote on 7 Jul 2016, 22:24 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?

        R 1 Reply Last reply 8 Jul 2016, 06:31
        0
        • M mongrelmac
          7 Jul 2016, 22:24

          @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?

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 8 Jul 2016, 06:31 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
          • M Offline
            M Offline
            mongrelmac
            wrote on 11 Jul 2016, 15:00 last edited by
            #5

            I see. Thanks @raven-worx @SGaist!

            1 Reply Last reply
            0

            5/5

            11 Jul 2016, 15:00

            • Login

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