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. The maximum value that a gauge can accept
Forum Updated to NodeBB v4.3 + New Features

The maximum value that a gauge can accept

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 877 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.
  • halimaH Offline
    halimaH Offline
    halima
    wrote on last edited by
    #1

    what is the the maximum value that a gauge can accept, because when i use this values the application crash!
    Thanks in advance

    Rectangle {
            width: 50
            height: 300
            anchors.centerIn: parent
            color: "transparent"
            property alias gauge: gauge_act_1
            Gauge {
                id: gauge_act_1
                maximumValue: 481900
                minimumValue: 357100
                value: 410841
                font.pixelSize: 9
                anchors.centerIn: parent
                anchors.leftMargin: 2
                anchors.rightMargin: 2
                formatValue: function(value) {
                    return value.toFixed(1);
                }            
    
                style: GaugeStyle {
    
                    valueBar: Rectangle {
                        color: "#FF003399"
                        implicitWidth: 15
                    }
                }
                objectName: "gauge_act_1"
            }
        }
    
    1 Reply Last reply
    0
    • D Offline
      D Offline
      DavidM29
      wrote on last edited by DavidM29
      #2

      @halima

      Your problem is not due to the maximum value but the step between each value. By default the step is 10 I let you do the count but it is way to many tick marks to put on the screen.

      Here the doc : tickMarkStepSize

      Try this code :

          Rectangle {
                  width: 50
                  height: 300
                  anchors.centerIn: parent
                  color: "transparent"
                  property alias gauge: gauge_act_1
                  Gauge {
                      id: gauge_act_1
                      maximumValue: 481900
                      minimumValue: 357100
                      tickmarkStepSize : 10000  //This is what is going to help you here
                      value: 410841
                      font.pixelSize: 9
                      anchors.centerIn: parent
                      anchors.leftMargin: 2
                      anchors.rightMargin: 2
                      formatValue: function(value) {
                          return value.toFixed(1);
                      }
      
                      style: GaugeStyle {
      
                          valueBar: Rectangle {
                              color: "#FF003399"
                              implicitWidth: 15
                          }
                      }
                      objectName: "gauge_act_1"
                  }
              }
      

      You probably don't need this anymore :

       formatValue: function(value) {
                          return value.toFixed(1);
                      }
      

      Because you are using int values.

      0_1531305036646_3eaadae3-dcde-48b0-b0b3-5f7f0339a310-image.png

      halimaH 1 Reply Last reply
      0
      • D DavidM29

        @halima

        Your problem is not due to the maximum value but the step between each value. By default the step is 10 I let you do the count but it is way to many tick marks to put on the screen.

        Here the doc : tickMarkStepSize

        Try this code :

            Rectangle {
                    width: 50
                    height: 300
                    anchors.centerIn: parent
                    color: "transparent"
                    property alias gauge: gauge_act_1
                    Gauge {
                        id: gauge_act_1
                        maximumValue: 481900
                        minimumValue: 357100
                        tickmarkStepSize : 10000  //This is what is going to help you here
                        value: 410841
                        font.pixelSize: 9
                        anchors.centerIn: parent
                        anchors.leftMargin: 2
                        anchors.rightMargin: 2
                        formatValue: function(value) {
                            return value.toFixed(1);
                        }
        
                        style: GaugeStyle {
        
                            valueBar: Rectangle {
                                color: "#FF003399"
                                implicitWidth: 15
                            }
                        }
                        objectName: "gauge_act_1"
                    }
                }
        

        You probably don't need this anymore :

         formatValue: function(value) {
                            return value.toFixed(1);
                        }
        

        Because you are using int values.

        0_1531305036646_3eaadae3-dcde-48b0-b0b3-5f7f0339a310-image.png

        halimaH Offline
        halimaH Offline
        halima
        wrote on last edited by halima
        #3

        @DavidM29
        thanks for your answer it helped me a lot! I used int values for test only but normally i use doubles.
        I do not preside the tickMarkStepSize value because the max and min are dynamic values.
        Do you have an idea to calculate the tickMarkStepSize using the max and min without giving a fixed value .
        I use this formula for the moment I do not know if it is correct

        tickmarkStepSize:( gauge_act_1.maximumValue - gauge_act_1.minimumValue)*0.1
        
        D 1 Reply Last reply
        0
        • halimaH halima

          @DavidM29
          thanks for your answer it helped me a lot! I used int values for test only but normally i use doubles.
          I do not preside the tickMarkStepSize value because the max and min are dynamic values.
          Do you have an idea to calculate the tickMarkStepSize using the max and min without giving a fixed value .
          I use this formula for the moment I do not know if it is correct

          tickmarkStepSize:( gauge_act_1.maximumValue - gauge_act_1.minimumValue)*0.1
          
          D Offline
          D Offline
          DavidM29
          wrote on last edited by
          #4

          @halima

          I believe there is no right or wrong formula it depends on what you want to display on your gauge.
          With your formula you will have always have 11 tick marks if this suits your need your formula is good no needs for another one.
          Your formula is taking the range of your gauge and divided it by 10 if you want an easy way to change the number of tick marks you can do this :

              property int  amountOfTick: 10 //Here you set the amount of tick you want
          
              Rectangle {
                  width: 50
                  height: 300
                  anchors.centerIn: parent
                  color: "transparent"
                  property alias gauge: gauge_act_1
                  Gauge {
                      id: gauge_act_1
                      minorTickmarkCount: 2
                      font.pixelSize: 9
                      anchors.centerIn: parent
                      anchors.leftMargin: 2
                      anchors.rightMargin: 2
                      maximumValue : 481000
                      minimumValue: 357000
                      value : 420000
                      tickmarkStepSize:( gauge_act_1.maximumValue - gauge_act_1.minimumValue)/(amountOfTick-1) //Here is the step calculation depending on the amount of tick you expect
                      formatValue: function(value) {
                          return value.toFixed(1);
                      }
          
                      style: GaugeStyle {
          
                          valueBar: Rectangle {
                              color: "#FF003399"
                              implicitWidth: 15
                          }
                      }
                      objectName: "gauge_act_1"
                  }
              }
          

          Hope this help you.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DavidM29
            wrote on last edited by
            #5

            @halima Is your problem solved ? If yes you can change its status.

            halimaH 1 Reply Last reply
            0
            • D DavidM29

              @halima Is your problem solved ? If yes you can change its status.

              halimaH Offline
              halimaH Offline
              halima
              wrote on last edited by
              #6

              @DavidM29
              yes David thank you a lot!

              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