Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QList<QColor> exposed to QML via model role
Forum Updated to NodeBB v4.3 + New Features

QList<QColor> exposed to QML via model role

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 257 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.
  • M Offline
    M Offline
    Marek
    wrote on last edited by
    #1

    Hi
    I have QList<QColor> and I'm exposing it via role from cpp model to QML like this:

    case GradientColorRole: {
            QVariantList vl;
            for(QColor color:p->gradient_color) {
                vl.append(QVariant(color));
            }
            return vl;
        }
    

    Is there simpler one line method ?
    on QML side I have array gradient_color[0...n]

    Best,
    Marek

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      If you want the list of colors at QML side, this is the only option.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      M 1 Reply Last reply
      0
      • dheerendraD dheerendra

        If you want the list of colors at QML side, this is the only option.

        M Offline
        M Offline
        Marek
        wrote on last edited by Marek
        #3

        @dheerendra thanks, no more question on that subject ;)

        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