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

where is hsvHue()?



  • I'm trying to get Hue out of a color in Qt Quick Controls 2 5.11:

    MyObject{
         property color theColor:"white";
         value: {return theColor.hsvHue();}
    }
    
    This generates the error "TypeError: Property 'hsvHue' of object #ffffff is not a function"
    
    The documentation says: 
    "A color type has r, g, b and a properties that refer to the red, green, blue and alpha values of the color, respectively. Additionally it has hsvHue, hsvSaturation, hsvValue and hslHue, hslSaturation, hslLightness properties, which allow access to color values in HSV and HSL color models accordingly"
    
    What am I doing wrong here?
    
    
    

  • Lifetime Qt Champion

    Hi,

    You are trying to access a QColor method while you have color QML type.



  • Doh!

    Is there a way to get hue from a qml color?

    And why is the bit of about hsvHue() listed on the color QML type page? It seems to imply that hsvHue will work with a qml color...


  • Qt Champions 2018

    @igor_stravinsky said in where is hsvHue()?:

    value: {return theColor.hsvHue();}

    As the doc and the error message say, it's a property, not a function.
    You can use it like so:
    value: theColor.hsvHue


Log in to reply