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. How to change Shape color
QtWS25 Last Chance

How to change Shape color

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 3 Posters 789 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
    sene
    wrote on last edited by
    #1

    Hi. I created an arc shape via QML. I want to make another color only selected area in image. But i can't figure it out. I tried gradient fill but couldn't success. Any help?

    3ee65b64-0da5-49e9-9bb3-d7e49e8f84f6-image.png

    Code:

    ShapePath {
                id: pathFG
                strokeColor: "#0b0b0b"
                fillColor: "transparent"
                strokeStyle: ShapePath.DashLine
                dashPattern: [290, 6]
                strokeWidth: 2
    
                PathAngleArc {
                    radiusX: (mainWindow.width / 2) - (pathFG.strokeWidth / 2)
                    radiusY: (mainWindow.height / 2) - (pathFG.strokeWidth / 2)
                    centerX: (mainWindow.width / 2)
                    centerY: (mainWindow.height / 2)
                    startAngle: -220
                    sweepAngle: 260
                }
            }
    
    B 1 Reply Last reply
    0
    • S sene

      Hi. I created an arc shape via QML. I want to make another color only selected area in image. But i can't figure it out. I tried gradient fill but couldn't success. Any help?

      3ee65b64-0da5-49e9-9bb3-d7e49e8f84f6-image.png

      Code:

      ShapePath {
                  id: pathFG
                  strokeColor: "#0b0b0b"
                  fillColor: "transparent"
                  strokeStyle: ShapePath.DashLine
                  dashPattern: [290, 6]
                  strokeWidth: 2
      
                  PathAngleArc {
                      radiusX: (mainWindow.width / 2) - (pathFG.strokeWidth / 2)
                      radiusY: (mainWindow.height / 2) - (pathFG.strokeWidth / 2)
                      centerX: (mainWindow.width / 2)
                      centerY: (mainWindow.height / 2)
                      startAngle: -220
                      sweepAngle: 260
                  }
              }
      
      B Offline
      B Offline
      Bob64
      wrote on last edited by
      #2

      @sene never used this as it's not in my version, but don't you need to set the fillColor to something other than "transparent"?

      S 1 Reply Last reply
      0
      • B Bob64

        @sene never used this as it's not in my version, but don't you need to set the fillColor to something other than "transparent"?

        S Offline
        S Offline
        sene
        wrote on last edited by sene
        #3

        @Bob64 Thank you for reply. Actually fillColor fills inside the circle. I want change strokeColor which is marked with yellow pen.

        PS. the black stroke is another PathAngleArc.

        B 1 Reply Last reply
        0
        • S sene

          @Bob64 Thank you for reply. Actually fillColor fills inside the circle. I want change strokeColor which is marked with yellow pen.

          PS. the black stroke is another PathAngleArc.

          B Offline
          B Offline
          Bob64
          wrote on last edited by
          #4

          @sene OK, sorry - when you mentioned "selected area", it sounded like you meant the area enclosed by the arc.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            govind_ashrit
            wrote on last edited by
            #5

            @sene Do you need something like this ?
            c0e529ef-afc0-45fc-aa31-1cc412cf5733-image.png

            We could make the code concise with repeater/model containing the stroke color, startAngle and sweepAngle

            Shape{
                ShapePath {
                    id: redquadrant
                    strokeColor: "red"
                    fillColor: "transparent"
                    strokeStyle: ShapePath.DashLine
                    dashPattern: [290, 6]
                    strokeWidth: 2
                    PathAngleArc {
                        radiusX: (mainWindow.width / 2) - (redquadrant.strokeWidth / 2)
                        radiusY: (mainWindow.height / 2) - (redquadrant.strokeWidth / 2)
                        centerX: (mainWindow.width / 2)
                        centerY: (mainWindow.height / 2)
                        startAngle: -180
                        sweepAngle: 180
                    }
                  }
                ShapePath {
                    id: yellowquadrant
                    strokeColor: "yellow"
                    fillColor: "transparent"
                    strokeStyle: ShapePath.DashLine
                    dashPattern: [290, 6]
                    strokeWidth: 2
                    PathAngleArc {
            
                        radiusX: (mainWindow.width / 2) - (yellowquadrant.strokeWidth / 2)
                        radiusY: (mainWindow.height / 2) - (yellowquadrant.strokeWidth / 2)
                        centerX: (mainWindow.width / 2)
                        centerY: (mainWindow.height / 2)
                        startAngle: 0
                        sweepAngle: 100
                    }
                  }
                ShapePath {
                    id: greenquadrant
                    strokeColor: "green"
                    fillColor: "transparent"
                    strokeStyle: ShapePath.DashLine
                    dashPattern: [290, 6]
                    strokeWidth: 2
                    PathAngleArc {
            
                        radiusX: (mainWindow.width / 2) - (greenquadrant.strokeWidth / 2)
                        radiusY: (mainWindow.height / 2) - (greenquadrant.strokeWidth / 2)
                        centerX: (mainWindow.width / 2)
                        centerY: (mainWindow.height / 2)
                        startAngle:  100
                        sweepAngle: 90
                    }
                  }
            }
            

            Let me know if this helps.

            Regards,
            govind

            S 1 Reply Last reply
            0
            • G govind_ashrit

              @sene Do you need something like this ?
              c0e529ef-afc0-45fc-aa31-1cc412cf5733-image.png

              We could make the code concise with repeater/model containing the stroke color, startAngle and sweepAngle

              Shape{
                  ShapePath {
                      id: redquadrant
                      strokeColor: "red"
                      fillColor: "transparent"
                      strokeStyle: ShapePath.DashLine
                      dashPattern: [290, 6]
                      strokeWidth: 2
                      PathAngleArc {
                          radiusX: (mainWindow.width / 2) - (redquadrant.strokeWidth / 2)
                          radiusY: (mainWindow.height / 2) - (redquadrant.strokeWidth / 2)
                          centerX: (mainWindow.width / 2)
                          centerY: (mainWindow.height / 2)
                          startAngle: -180
                          sweepAngle: 180
                      }
                    }
                  ShapePath {
                      id: yellowquadrant
                      strokeColor: "yellow"
                      fillColor: "transparent"
                      strokeStyle: ShapePath.DashLine
                      dashPattern: [290, 6]
                      strokeWidth: 2
                      PathAngleArc {
              
                          radiusX: (mainWindow.width / 2) - (yellowquadrant.strokeWidth / 2)
                          radiusY: (mainWindow.height / 2) - (yellowquadrant.strokeWidth / 2)
                          centerX: (mainWindow.width / 2)
                          centerY: (mainWindow.height / 2)
                          startAngle: 0
                          sweepAngle: 100
                      }
                    }
                  ShapePath {
                      id: greenquadrant
                      strokeColor: "green"
                      fillColor: "transparent"
                      strokeStyle: ShapePath.DashLine
                      dashPattern: [290, 6]
                      strokeWidth: 2
                      PathAngleArc {
              
                          radiusX: (mainWindow.width / 2) - (greenquadrant.strokeWidth / 2)
                          radiusY: (mainWindow.height / 2) - (greenquadrant.strokeWidth / 2)
                          centerX: (mainWindow.width / 2)
                          centerY: (mainWindow.height / 2)
                          startAngle:  100
                          sweepAngle: 90
                      }
                    }
              }
              

              Let me know if this helps.

              Regards,
              govind

              S Offline
              S Offline
              sene
              wrote on last edited by sene
              #6

              @govind_ashrit Thank you for your reply. Sorry I didn't mention it but my sweepAngle changing dynamically. The value coming from a C++ script. When I try your example the shapes rotating independently. So what I want is when first shape reaching last point other colored shape starting rotate.

              Basically like this. I try the gradient but didn't work for me.

              alt text

              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