Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED ]color dialog currentColor offline seting



  • 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


  • Moderators

    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
    @



  • 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!!


  • Moderators

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



  • 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


Log in to reply