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. Gauge strange margin and labels problems
Forum Updated to NodeBB v4.3 + New Features

Gauge strange margin and labels problems

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
gaugescalingmarginlabel
1 Posts 1 Posters 242 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.
  • K Offline
    K Offline
    Kyeiv
    wrote on last edited by Kyeiv
    #1

    I noticed strange Gauge behavior when scaling it.

    when it is big enough its look is acceptable:
    Screenshot from 2021-10-08 12-41-12.png

    but when smaller it gets margin from the left side:
    Screenshot from 2021-10-08 12-40-12.png

    also as you can see the labels are not centered vertically to tickmarks.

    How can it be fixed?

    My code:

    Gauge {
        Rectangle{
            anchors.fill: parent
            color: "transparent"
            border.color: "red"
        }
    
        value: 10
    
        implicitHeight: barHeight
        implicitWidth: barWidth //both width and height depend on the screen size example: width: screen.width / 6
    
        style: GaugeStyle {
            valueBar: Rectangle {
                implicitWidth: control.implicitWidth * (1/3)
                color: "green"
            }
    
            minorTickmark: Item {
                implicitWidth: control.implicitWidth * (1/3) * (1/4)
                implicitHeight: 1
    
                Rectangle {
                    color: "#cccccc"
                    anchors.fill: parent
                    anchors.leftMargin: 2
                    anchors.rightMargin: 4
                }
            }
    
            tickmark: Item {
                implicitWidth: control.implicitWidth * (1/3) * (1/2)
                implicitHeight: 1
    
                Rectangle {
                    color: "#c8c8c8"
                    anchors.fill: parent
                    anchors.leftMargin: 3
                    anchors.rightMargin: 3
                }
            }
    
            tickmarkLabel:  Text {
                font.pixelSize: control.implicitWidth * 0.1
                text: styleData.value
                color: "#e5e5e5"
                antialiasing: true
            }
        }
    }
    
    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