Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Repainting issue in QML
Qt 6.12 LTS is out! See what's new in the release blog

Repainting issue in QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
8 Posts 2 Posters 1.0k 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.
  • S Offline
    S Offline
    Sanjeev Gudisagar
    wrote on last edited by
    #1

    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
        }
    }
    

    }

    1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by
      #2

      I cannot reproduce the problem.

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

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sanjeev Gudisagar
        wrote on last edited by Sanjeev Gudisagar
        #3

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

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Sanjeev Gudisagar
          wrote on last edited by Sanjeev Gudisagar
          #4

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

          1 Reply Last reply
          0
          • MarkkyboyM Offline
            MarkkyboyM Offline
            Markkyboy
            wrote on last edited by
            #5

            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.

            Don't just sit there standing around, pick up a shovel and sweep up!

            I live by the sea, not in it.

            1 Reply Last reply
            0
            • MarkkyboyM Offline
              MarkkyboyM Offline
              Markkyboy
              wrote on last edited by
              #6

              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.
              

              Don't just sit there standing around, pick up a shovel and sweep up!

              I live by the sea, not in it.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                Sanjeev Gudisagar
                wrote on last edited by
                #7

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

                MarkkyboyM 1 Reply Last reply
                0
                • S Sanjeev Gudisagar

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

                  MarkkyboyM Offline
                  MarkkyboyM Offline
                  Markkyboy
                  wrote on last edited by
                  #8

                  @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.

                  Don't just sit there standing around, pick up a shovel and sweep up!

                  I live by the sea, not in it.

                  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
                  • Unsolved