Home > Software design >  How to set value of Speedometer in QML?
How to set value of Speedometer in QML?

Time:08-05

I have such piece of code in my QML file, which handle the CircularGauge:

            CircularGauge
            {
                id: speedometer
                objectName: speedometer
                x: 230
                value: valueSource.kph 
                minimumValue: 0
                maximumValue: 180
                width: 730
                anchors.top: parent.top
                anchors.bottom: parent.bottom
                anchors.bottomMargin: -34
                anchors.topMargin: -505
                antialiasing: true
                style: DashboardGaugeStyle{}

                Connections
                {
                    target: connection

                    function onTestSignal(num){
                        speedometer.value(num); // here - the typeError
                    }
                }

However I'm keep getting an error: TypeError: Type error when trying to set some value

My testSignal is definied like this:

void testSignal(int num);

CodePudding user response:

You are setting the value the wrong way. It's not a function that you call. It's a property that you set, like this:

speedometer.value = num;
  • Related