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. [SOLVED ]color dialog currentColor offline seting
QtWS25 Last Chance

[SOLVED ]color dialog currentColor offline seting

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.1k 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
    mehrdad
    wrote on last edited by
    #1

    there is a ridiculous problem here
    i have a list like this:

    property color["red","blue"]

    and i want to change both blue and red color to green and yellow for example an i use one color dialog for this work as:
    @
    ColorDialog{
    id:cd
    property int itemw
    showAlphaChannel: true
    onAccepted:{
    color[itemw]=currentColor
    }
    }@
    and my problem is that currentColor will be set to my list dynamicly and in fact for itemw=1 my list change to

    property color["red",currentColor]

    and if i change color list first item by this code the second one give this color olso

    i can solve this problem by using a string temp variable as:
    @
    ColorDialog{
    id:cd
    property int itemw
    property string temp
    showAlphaChannel: true
    onAccepted:{
    temp=currentColor
    color[itemw]=temp
    }
    }@
    but opacity of color does not send to list and unfortunately i need it in my list
    and also this list is dynamic and i cant use two colorDialog to solve my problem

    and my question simple form is how can set a variable value to a list element and not put it in that

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Instead use var type
      @
      property var colors : ["red","blue"]

      ...
      onAccepted: {
      colors[colors.length+1] = currentColor
      console.log(colors)
      }
      @

      To get the transparency i.e alpha value, use:
      @
      currentColor.a
      @

      157

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mehrdad
        wrote on last edited by
        #3

        thanks my friend but first code does not work...
        but thanks again because second one
        i guess something and use
        @
        Qt.rgba(currentColor.r,currentColor.g,currentColor.b,currentColor.a)
        @
        and it work :)
        merci!!

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          or you can use currentAlpha ;)
          Regarding the first question, why didn't it work ? What error did you get ?

          157

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mehrdad
            wrote on last edited by
            #5

            i know about currentAlpha but .r .g .b :)
            same problem...when i change first color its ok
            second color change change also first color to currentColor

            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