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. Make a round progress bar
QtWS25 Last Chance

Make a round progress bar

Scheduled Pinned Locked Moved Solved QML and Qt Quick
16 Posts 4 Posters 6.7k 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.
  • D DavidM29
    14 Jun 2018, 12:59

    @sierdzio here is the result : 0_1528981120882_e09a41d0-53ee-4ee6-b99a-1128d1d126bf-image.png

    Never used Canvas or QuickItem painting. Can you guide me a bit through this ?

    K Offline
    K Offline
    KillerSmath
    wrote on 14 Jun 2018, 13:36 last edited by KillerSmath
    #7

    @DavidM29

    The clip effect is based on rectangle, so, you can reimplement this effect in paint render (c++) or you can use a "rectangle" (item) to shape the inner circle.

       Rectangle{
            property int percentage: 100
            id: root
            width: 300
            height: 300
            radius: width / 2
    
            color: "white"
            border.color: "#385d8a"
            border.width: 5
    
            Item{
                anchors.bottom: parent.bottom
                anchors.left: parent.left
                anchors.right: parent.right
                height: parent.height * parent.percentage / 100
                clip: true
    
                Rectangle{
                    width: root.width - root.border.width * 2
                    height: root.height - root.border.width * 2
                    radius: width / 2
                    anchors.bottom: parent.bottom
                    anchors.left: parent.left
                    anchors.margins: root.border.width
                    color: "red"
                }
            }
    
            Text{
                anchors.centerIn: parent
                font.pixelSize: 20
                text: root.percentage.toString() + "%"
            }
        }
    

    @Computer Science Student - Brazil
    Web Developer and Researcher
    “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

    1 Reply Last reply
    3
    • D Offline
      D Offline
      DavidM29
      wrote on 14 Jun 2018, 14:28 last edited by
      #8

      Works nicely ! Thank you !
      I have another question :
      For an image is it possible to do the same for example, considering this as an image : 0_1528986288161_a26de074-5e6d-4bd8-9026-f483576dfd67-image.png

      like a .svg file, would it be possible to color just the circle of the image with the same rendering ?

      If you want I can make a new post for this.

      K 1 Reply Last reply 14 Jun 2018, 14:50
      0
      • D DavidM29
        14 Jun 2018, 14:28

        Works nicely ! Thank you !
        I have another question :
        For an image is it possible to do the same for example, considering this as an image : 0_1528986288161_a26de074-5e6d-4bd8-9026-f483576dfd67-image.png

        like a .svg file, would it be possible to color just the circle of the image with the same rendering ?

        If you want I can make a new post for this.

        K Offline
        K Offline
        KillerSmath
        wrote on 14 Jun 2018, 14:50 last edited by KillerSmath
        #9

        @DavidM29
        I believe for image you can apply a mask in the image
        This post has a good solution:
        https://stackoverflow.com/a/32710773

        Opacity Mask Documentation

        @Computer Science Student - Brazil
        Web Developer and Researcher
        “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DavidM29
          wrote on 14 Jun 2018, 15:10 last edited by
          #10

          I believe I did not express my self clearly.

          From the the image on my previous post I would like to know how to do something like that : 0_1528988622710_d44ac1e5-cc85-4650-bda8-86456d5e1ce3-image.png
          The idea is to have a variable part on the image.
          Maybe it should be separate in different step like that :
          0_1528989011848_ca971153-fdd1-4bf6-8d16-1abd16987118-image.png
          The background would be always present and the filling appear partially depending on the value.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            KillerSmath
            wrote on 14 Jun 2018, 15:25 last edited by
            #11

            @DavidM29 do you want to create an animation of loading of image starting on bottom and ending on top ?

            @Computer Science Student - Brazil
            Web Developer and Researcher
            “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DavidM29
              wrote on 14 Jun 2018, 15:32 last edited by DavidM29
              #12

              I want to animated just a part of the image. I want to keep a constant part. Assuming this image : 0_1528990242450_05ee0e6a-2f07-4a6c-a1c2-3be18735717e-image.png
              I want to keep the wheel and glass but I want to animate the Orange color of the car. Loading like the circle on the previous messages.
              Not sure it is very clear. I'm trying to find a real exemple somewhere.

              Edit :

              Like here https://cdn.dribbble.com/users/100142/screenshots/2920352/loading-animation-cd-v2.gif
              There is the middle of the display animated and the rest of it is fixed. I would like to anime the display from bottom to top and keeping the border fixed.
              Or from the example above Fill my background image on the transparent circle with the red circle.

              K 1 Reply Last reply 14 Jun 2018, 15:44
              0
              • D DavidM29
                14 Jun 2018, 15:32

                I want to animated just a part of the image. I want to keep a constant part. Assuming this image : 0_1528990242450_05ee0e6a-2f07-4a6c-a1c2-3be18735717e-image.png
                I want to keep the wheel and glass but I want to animate the Orange color of the car. Loading like the circle on the previous messages.
                Not sure it is very clear. I'm trying to find a real exemple somewhere.

                Edit :

                Like here https://cdn.dribbble.com/users/100142/screenshots/2920352/loading-animation-cd-v2.gif
                There is the middle of the display animated and the rest of it is fixed. I would like to anime the display from bottom to top and keeping the border fixed.
                Or from the example above Fill my background image on the transparent circle with the red circle.

                K Offline
                K Offline
                KillerSmath
                wrote on 14 Jun 2018, 15:44 last edited by
                #13

                @DavidM29
                Something like that:

                Item{
                        width: 350
                        height: 150
                        anchors.centerIn: parent
                        Rectangle{
                            id: rect
                            color: "steelblue"
                            width: 350
                            anchors.bottom: parent.bottom
                
                            SequentialAnimation{
                                running: true
                                loops: Animation.Infinite
                                NumberAnimation{
                                    target: rect
                                    properties: "height"
                                    from: 0
                                    to: 150
                                    duration: 5000
                                }
                                NumberAnimation{
                                    target: rect
                                    properties: "height"
                                    from: 150
                                    to: 0
                                    duration: 5000
                                }
                            }
                        }
                    }
                

                @Computer Science Student - Brazil
                Web Developer and Researcher
                “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

                D 1 Reply Last reply 14 Jun 2018, 15:50
                2
                • K KillerSmath
                  14 Jun 2018, 15:44

                  @DavidM29
                  Something like that:

                  Item{
                          width: 350
                          height: 150
                          anchors.centerIn: parent
                          Rectangle{
                              id: rect
                              color: "steelblue"
                              width: 350
                              anchors.bottom: parent.bottom
                  
                              SequentialAnimation{
                                  running: true
                                  loops: Animation.Infinite
                                  NumberAnimation{
                                      target: rect
                                      properties: "height"
                                      from: 0
                                      to: 150
                                      duration: 5000
                                  }
                                  NumberAnimation{
                                      target: rect
                                      properties: "height"
                                      from: 150
                                      to: 0
                                      duration: 5000
                                  }
                              }
                          }
                      }
                  
                  D Offline
                  D Offline
                  DavidM29
                  wrote on 14 Jun 2018, 15:50 last edited by
                  #14

                  @KillerSmath

                  Yes exactly but with a constant border wich is like an image.

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    KillerSmath
                    wrote on 14 Jun 2018, 16:42 last edited by KillerSmath
                    #15

                    @DavidM29
                    Using the previous posts, you can use mask with rectangle loader.

                    Obs: the maximum radius = min_between(width, height) / 2

                    Code

                    import QtQuick 2.8
                    import QtGraphicalEffects 1.0
                    
                      Rectangle{
                            property int imgRadius: Math.min(imgContainer.width, imgContainer.height) / 2
                            property int borderWidth: 3
                    
                            id: imgContainer
                            width: 190
                            height: 190
                            anchors.centerIn: parent
                            color: "#f2f2f2"
                            border.color: "#385d8a"
                            border.width: borderWidth
                            radius: imgRadius
                    
                            Image {
                                id: img
                                anchors.fill: parent
                                source: "https://www.gnu.org/graphics/nu-gnu.svg"
                                layer.enabled: true
                                layer.effect: OpacityMask {
                                    maskSource: Item {
                                        width: imgContainer.width
                                        height: imgContainer.height
                                        Rectangle{
                                            id: rectContainer
                                            width: parent.width
                                            anchors.bottom: parent.bottom
                                            clip: true
                                            color: "transparent"
                                            Rectangle {
                                                id: rectMask
                                                anchors.bottom: parent.bottom
                                                anchors.left: parent.left
                                                anchors.right: parent.right
                                                anchors.margins: imgContainer.borderWidth
                                                height: img.height - imgContainer.borderWidth * 2
                                                radius: Math.max(0, imgContainer.imgRadius-imgContainer.borderWidth)
                                            }
                                            SequentialAnimation{
                                                running: img.status == Image.Ready
                                                loops: Animation.Infinite
                    
                                                NumberAnimation{
                                                    target: rectContainer
                                                    properties: "height"
                                                    from: 0
                                                    to: img.height
                                                    duration: 5000
                                                }
                                                PauseAnimation{
                                                    duration: 1000
                                                }
                    
                                                NumberAnimation{
                                                    target: rectContainer
                                                    properties: "height"
                                                    from: img.height
                                                    to: 0
                                                    duration: 5000
                                                }
                    
                                                PauseAnimation{
                                                    duration: 1000
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    

                    0_1529001399131_gggg.gif

                    Full Code Link - Git Hub

                    @Computer Science Student - Brazil
                    Web Developer and Researcher
                    “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

                    1 Reply Last reply
                    6
                    • D Offline
                      D Offline
                      DavidM29
                      wrote on 15 Jun 2018, 05:42 last edited by
                      #16

                      That is close to what I want but this will work only on standard shape like rectangle or circle. If I wan't to have this effect inside an image it will not work doesn't it ?

                      1 Reply Last reply
                      0

                      16/16

                      15 Jun 2018, 05:42

                      • Login

                      • Login or register to search.
                      16 out of 16
                      • First post
                        16/16
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved