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

Repainting issue in QML



  • When i move between 1st and 2nd second rectangle i could see 3rd and 4th texts inside rectangle are getting repainted.
    Please enable "QSG_VISUALIZE = batches" in build environment

    here is the code:
    import QtQuick 2.0

    Item {
    anchors.fill: parent

    Component.onCompleted: {
        rect1.focus=true
    }
    
    
    Item{
        id:rect1
        width: 80
        height: parent.height
        x:0
        property bool isfocus : rect1.focus
    
        Rectangle{
            id:r1
            width: parent.width
            height: parent.height
            color: rect1.isfocus  ? "red":"yellow"
        }
    
        Text {
            id: name1
            anchors.centerIn: parent
            text: "AAA"
            color: rect1.isfocus? "yellow":"red"
        }
    
        Keys.onRightPressed: {
            rect2.focus=true
        }
    }
    
    Item{
        id:rect2
        width: 80
        height: parent.height
        x:100
        property bool isfocus : rect2.focus
    
        Rectangle{
            width: parent.width
            height: parent.height
            color: rect2.isfocus? "red":"yellow"
        }
        Text {
            id: name2
            text: "BBB"
            anchors.centerIn: parent
            color: rect2.isfocus? "yellow":"red"
        }
        Keys.onRightPressed: {
            rect3.focus=true
        }
    
        Keys.onLeftPressed: {
            rect1.focus=true
        }
    }
    
    Item{
        id:rect3
        width: 80
        height: parent.height
        x:200
        property bool isfocus : rect3.focus
        Rectangle{
            width: parent.width
            height: parent.height
            color: rect3.isfocus? "red":"yellow"
        }
        Text {
            id: name3
            text: "CCC"
            anchors.centerIn: parent
            color: rect3.isfocus? "yellow":"red"
        }
    
        Keys.onRightPressed: {
            rect4.focus=true
        }
    
        Keys.onLeftPressed:  {
            rect2.focus=true
        }
    }
    Item{
        id:rect4
        width: 80
        height: parent.height
        x:300
        property bool isfocus : rect4.focus
        Rectangle{
            id:r4
            width: parent.width
            height: parent.height
            color: rect4.isfocus  ? "red":"yellow"
        }
    
        Text {
            id: name4
            text: "DDD"
            anchors.centerIn: parent
            color: rect4.isfocus? "yellow":"red"
        }
    
        Keys.onLeftPressed:  {
            rect3.focus=true
        }
    }
    

    }



  • I cannot reproduce the problem.

    Also, I did not enable "QSG_VISUALIZE=batches", could this be why I am not seeing your problem?



  • @Markkyboy Thank you for replying. Yes, You have to enable "QSG_VISUALIZE = batches" to see repaiting Capture333.PNG



  • @Markkyboy you will see something like this if you run with batchesCapture2.PNG



  • Yes, okay, I now have the same as you show in your image. Seems like the logic in main.qml regarding focus is adrift, but I can't figure out how.....yet.



  • Okay, this makes some difference, try this;

            Item{
                id: rect1
                width: 80
                height: parent.height
                x: 0
                //property bool isfocus : rect1.focus <-----hide this and run again.
    


  • @Markkyboy If i comment that line the focus doesn't work for rect1. To see original behavior please unset "QSG_VISUALIZE = batches". Capture21.PNG



  • @Sanjeev-Gudisagar - yes, sorry, my bad. I got carried away with QSG mode I forgot to uncheck it and see what happens in normal mode.
    It sure is a perplexing problem, I spent a few hours fiddling with your code.


Log in to reply