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. Shape quality does not change even if layer.samples of item is changed dynamically
Forum Update on Monday, May 27th 2025

Shape quality does not change even if layer.samples of item is changed dynamically

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 783 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.
  • Y Offline
    Y Offline
    ynakane
    wrote on last edited by ynakane
    #1

    Hi.
    I want to change the quality of anti-aliasing by click operations.

    [High-quality]
    スクリーンショット 2023-08-05 16.18.53.png

    [Low-quality]
    スクリーンショット 2023-08-05 16.14.38.png

    I found that setting an appropriate value (for example 8) for layer.samples improved the graphics.
    I want to make an application that dynamically changes the graphics quality, but dynamic changing layer.samples didn't change quality of edges.
    The initial value (8) seems to be in effect all the time.
    Below is a snippet of the code.
    Does anyone knows the cause?

    import QtQuick 2.15
    import QtQuick.Window 2.15
    import QtQuick.Shapes 1.15
    
    Window {
        id: root
        width: 640
        height: 480
        visible: true
    
        property int samples: 8
    
        Item {
            id: item
            anchors.fill: parent
            layer.enabled: true
            layer.samples: root.samples
            layer.onSamplesChanged: console.log(root.samples)
    
            Shape{
                id: circle
                anchors.fill: parent
                property real r: Math.min(root.width, root.height) / 2 - 2
    
                ShapePath{
                    strokeStyle: ShapePath.SolidLine
                    strokeWidth: 2
                    strokeColor: "black"
                    fillColor: "transparent"
    
                    startX: root.width / 2
                    startY: root.height / 2
    
                    PathAngleArc {
                        centerX: root.width / 2
                        centerY: root.height / 2
                        radiusX: circle.r
                        radiusY: circle.r
                        startAngle: 0
                        sweepAngle: 360
                    }
                }
            }
            MouseArea{
                anchors.fill: parent
                onClicked: {
    
                    if(root.samples == 0)
                        root.samples = 8
                    else
                        root.samples = 0
    
                    item.update()
                }
            }
        }
    }
    
    
    johngodJ 1 Reply Last reply
    0
    • Y ynakane

      Hi.
      I want to change the quality of anti-aliasing by click operations.

      [High-quality]
      スクリーンショット 2023-08-05 16.18.53.png

      [Low-quality]
      スクリーンショット 2023-08-05 16.14.38.png

      I found that setting an appropriate value (for example 8) for layer.samples improved the graphics.
      I want to make an application that dynamically changes the graphics quality, but dynamic changing layer.samples didn't change quality of edges.
      The initial value (8) seems to be in effect all the time.
      Below is a snippet of the code.
      Does anyone knows the cause?

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import QtQuick.Shapes 1.15
      
      Window {
          id: root
          width: 640
          height: 480
          visible: true
      
          property int samples: 8
      
          Item {
              id: item
              anchors.fill: parent
              layer.enabled: true
              layer.samples: root.samples
              layer.onSamplesChanged: console.log(root.samples)
      
              Shape{
                  id: circle
                  anchors.fill: parent
                  property real r: Math.min(root.width, root.height) / 2 - 2
      
                  ShapePath{
                      strokeStyle: ShapePath.SolidLine
                      strokeWidth: 2
                      strokeColor: "black"
                      fillColor: "transparent"
      
                      startX: root.width / 2
                      startY: root.height / 2
      
                      PathAngleArc {
                          centerX: root.width / 2
                          centerY: root.height / 2
                          radiusX: circle.r
                          radiusY: circle.r
                          startAngle: 0
                          sweepAngle: 360
                      }
                  }
              }
              MouseArea{
                  anchors.fill: parent
                  onClicked: {
      
                      if(root.samples == 0)
                          root.samples = 8
                      else
                          root.samples = 0
      
                      item.update()
                  }
              }
          }
      }
      
      
      johngodJ Offline
      johngodJ Offline
      johngod
      wrote on last edited by
      #2

      @ynakane Hi I dont know the cause but I am guessing since there is not change in the Item it does not update. If you change the size of the window with the mouse you will see that the quality does indeed updates.
      One ugly hack I found is to draw a rectangle of 0 widht and height and move it inside the Item whenever you want to trigger the quality change. Let me know when you find a proper fix.

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import QtQuick.Shapes 1.15
      
      Window {
          id: root
          width: 640
          height: 480
          visible: true
      
          property int samples: 8
      
          Item {
              id: item
              anchors.fill: parent
      
              Rectangle {
                  id: rect
                  width: 0
                  height: 0
                  color: "white"
              }
      
              layer.enabled: true
              layer.samples: root.samples
              layer.onSamplesChanged: console.log(root.samples)
      
              Shape{
                  id: circle
                  anchors.fill: parent
                  property real r: Math.min(root.width, root.height) / 2 - 2
      
      
      
                  ShapePath{
                      strokeStyle: ShapePath.SolidLine
                      strokeWidth: 2
                      strokeColor: "black"
                      fillColor: "transparent"
      
                      startX: root.width / 2
                      startY: root.height / 2
      
                      PathAngleArc {
                          centerX: root.width / 2
                          centerY: root.height / 2
                          radiusX: circle.r
                          radiusY: circle.r
                          startAngle: 0
                          sweepAngle: 360
                      }
                  }
              }
              MouseArea{
                  anchors.fill: parent
                  onClicked: {
      
                      if(root.samples == 0) {
                          root.samples = 8
                          rect.x++
                          //root.update()
      
                      }
                      else{
                          root.samples = 0
                          rect.x--
                          //root.update()
                      }
                  }
              }
          }
      }
      
      Y 1 Reply Last reply
      0
      • johngodJ johngod

        @ynakane Hi I dont know the cause but I am guessing since there is not change in the Item it does not update. If you change the size of the window with the mouse you will see that the quality does indeed updates.
        One ugly hack I found is to draw a rectangle of 0 widht and height and move it inside the Item whenever you want to trigger the quality change. Let me know when you find a proper fix.

        import QtQuick 2.15
        import QtQuick.Window 2.15
        import QtQuick.Shapes 1.15
        
        Window {
            id: root
            width: 640
            height: 480
            visible: true
        
            property int samples: 8
        
            Item {
                id: item
                anchors.fill: parent
        
                Rectangle {
                    id: rect
                    width: 0
                    height: 0
                    color: "white"
                }
        
                layer.enabled: true
                layer.samples: root.samples
                layer.onSamplesChanged: console.log(root.samples)
        
                Shape{
                    id: circle
                    anchors.fill: parent
                    property real r: Math.min(root.width, root.height) / 2 - 2
        
        
        
                    ShapePath{
                        strokeStyle: ShapePath.SolidLine
                        strokeWidth: 2
                        strokeColor: "black"
                        fillColor: "transparent"
        
                        startX: root.width / 2
                        startY: root.height / 2
        
                        PathAngleArc {
                            centerX: root.width / 2
                            centerY: root.height / 2
                            radiusX: circle.r
                            radiusY: circle.r
                            startAngle: 0
                            sweepAngle: 360
                        }
                    }
                }
                MouseArea{
                    anchors.fill: parent
                    onClicked: {
        
                        if(root.samples == 0) {
                            root.samples = 8
                            rect.x++
                            //root.update()
        
                        }
                        else{
                            root.samples = 0
                            rect.x--
                            //root.update()
                        }
                    }
                }
            }
        }
        
        Y Offline
        Y Offline
        ynakane
        wrote on last edited by
        #3

        @johngod Thank you for your answer. I try to your modified code and I got a result that I want.
        Unfortunately, I couldn't of came up with a better code change. I would like to implement this code for a while.
        Thank you for everything.

        johngodJ 1 Reply Last reply
        0
        • Y ynakane has marked this topic as solved on
        • Y ynakane

          @johngod Thank you for your answer. I try to your modified code and I got a result that I want.
          Unfortunately, I couldn't of came up with a better code change. I would like to implement this code for a while.
          Thank you for everything.

          johngodJ Offline
          johngodJ Offline
          johngod
          wrote on last edited by
          #4

          @ynakane
          If you want to, maybe ask around in the mailing list if this is a bug, and fill a bug report, just saying

          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