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. visibility of elements(rectangle) while using chartview in qml
Forum Updated to NodeBB v4.3 + New Features

visibility of elements(rectangle) while using chartview in qml

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 124 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.
  • U Offline
    U Offline
    unknown user
    wrote on last edited by
    #1

    I'm using ChartView in QML to display a histogram, and I want to overlay a Rectangle on top of it to act as a discriminator line. However, the rectangle is hidden beneath the chart. I've tried setting a high z value on the Rectangle, but it still doesn't show up.
    The strange part is that the rectangle becomes visible only after user interaction — such as a touch or a click on the screen. Until then, it's completely hidden.

    Rectangle{
    id: rectangle
    color: "#1A1A1A"
    anchors.fill: parent
    radius: 5

    ChartView {
        id:zoomedHistogram
        x: 0
        y: 0
        z: 0
        width: 100 + 400*1.25
        height: 394
        legend.visible: false
        antialiasing: true
       
    
        ValueAxis {
            id: axisX
            ..........................................
            ...................................................
        }
    
        ValueAxis {
            id: axisY
           ..........................................
           ...................................................
        }
        
        AreaSeries {
            axisY: axisY
           ..........................................
           ...................................................
            }
        }
    
    }
    
    Item{
        id : itemcombined
        z: 50
    
        Item{
            id: element1
            x: 56
            width: zoomedHistogram.d1/.256
            anchors.top: zoomedHistogram.bottom
            anchors.topMargin: 4
            height: 34
            z: 4
            y: zoomedHistogram.y + zoomedHistogram.height + 4
    
            Rectangle{
                id: colourRect
                color: ma.pressed ? "#2094FA" : "#3F3F3F"
                anchors.bottom: parent.bottom
                anchors.bottomMargin: 0
                anchors.top: parent.top
                anchors.topMargin: 0
                width: parent.width
            }
            Rectangle{
                id: colourLine
                color: ma.pressed ? "#2094FA" : "#363636"
                z: 200
                anchors.horizontalCenter: movingbutton.horizontalCenter
                anchors.bottomMargin: - 40
                width: 1
                height: zoomedHistogram.height + 5
                anchors.bottom: movingbutton.top
    
            }
    
            Rectangle{
                id: movingbutton
                height: 16
                width: 16
                radius: width/2
                anchors.verticalCenter: parent.verticalCenter
                x: parent.width
                color: "#000000"
                property var previous: 0
                onXChanged: {
                
                    colourRect.width = x + 8
             
                    if(previous>=movingbutton.x)
                        var asdf = Math.ceil(.256*movingbutton.x)
                    else
                        asdf = parseInt(.256*movingbutton.x)
                    previous = movingbutton.x
       
             
                    zoomedHistogram.d1 = Number(asdf)
                    if(ma.pressed){
                        window.onDraggedDescriminator()
                        window.totalSum()
                    }
                }
    
                MouseArea{
                    id: ma
                    enabled: parameters.totalSumWBC>0 ? true : false
                    anchors.fill: parent
                    drag.target: parent
                    drag.maximumX: zoomedHistogram.d2/.256 - 5
                    drag.minimumX: 0
                }
                Rectangle{
                    width: 5
                    height: 5
                    radius: width/2
                    color: ma.pressed ? "#2094FA" : "#363636"
                    anchors.centerIn: parent
                }
            }
    
        }
    

    }

    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