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 draw "WiFi icon" using QML

How to draw "WiFi icon" using QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 3 Posters 902 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.
  • M Offline
    M Offline
    Muktha PM
    wrote on 17 Jun 2022, 06:56 last edited by
    #1

    WiFi icon needs to be drawn in QML

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Markkyboy
      wrote on 17 Jun 2022, 09:07 last edited by
      #2

      Why must it be drawn?, for what purpose?, what are you trying to achieve?

      Why can you not simply use an existing icon in jpg/png/svg format?

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

      I live by the sea, not in it.

      M 1 Reply Last reply 21 Jun 2022, 12:07
      0
      • N Offline
        N Offline
        ndias
        wrote on 17 Jun 2022, 09:34 last edited by
        #3

        Hi @Muktha-PM,

        As @Markkyboy metioned before you can use a svg or png format to draw a WiFi icon. If you want draw it you can use shapepath to do it.

        You can find an simple draft below:

        import QtQuick
        import QtQuick.Shapes
        
        Item {
            id: wifiIcon
        
            width: parent.width < parent.height ? parent.width : parent.height
            height: width
            anchors.centerIn: parent
        
            Rectangle {
                anchors.horizontalCenter: wifiIcon.horizontalCenter
                anchors.bottom: wifiIcon.bottom
                
        
                // Set size and corner radius to define a circle
                width: wifiIcon.width/6
                height: wifiIcon.height/6
                radius: width/2
                
                color: "#4EC5F1"
                //border.color: "black"
                //border.width: 1
            }
        
            Shape {
                ShapePath {
                    fillColor: "transparent"
                    strokeColor: "#4EC5F1"
                    strokeWidth: wifiIcon.height/8
                    capStyle: ShapePath.RoundCap
                    PathAngleArc {
                        centerX: wifiIcon.height / 2
                        centerY: wifiIcon.width / 4 + wifiIcon.width / 4
                        radiusX: wifiIcon.width < wifiIcon.height ? wifiIcon.width/2 - wifiIcon.height/8 : wifiIcon.height/2 - wifiIcon.height/8
                        radiusY: radiusX
                        startAngle: 200
                        sweepAngle: 140
                    }
                }
        
                ShapePath {
                    fillColor: "transparent"
                    strokeColor: "#4EC5F1"
                    strokeWidth: wifiIcon.height/8
                    capStyle: ShapePath.RoundCap
                    PathAngleArc {
                        centerX: wifiIcon.height / 2
                        centerY: wifiIcon.width / 3 + wifiIcon.width / 4
                        radiusX: wifiIcon.width < wifiIcon.height ? wifiIcon.width/3 - wifiIcon.height/8 : wifiIcon.height/3 - wifiIcon.height/8
                        radiusY: radiusX
                        startAngle: 200
                        sweepAngle: 140
                    }
                }
        
                ShapePath {
                    fillColor: "transparent"
                    strokeColor: "#4EC5F1"
                    strokeWidth: wifiIcon.height/8
                    capStyle: ShapePath.RoundCap
                    PathAngleArc {
                        centerX: wifiIcon.height / 2
                        centerY: wifiIcon.width / 2 + wifiIcon.width / 4
                        radiusX: wifiIcon.width < wifiIcon.height ? wifiIcon.width/4 - wifiIcon.height/8 : wifiIcon.height/4 - wifiIcon.height/8
                        radiusY: radiusX
                        startAngle: 200
                        sweepAngle: 140
                    }
                }
            }
        }
        

        Regards

        M 1 Reply Last reply 29 Jun 2022, 06:31
        0
        • M Markkyboy
          17 Jun 2022, 09:07

          Why must it be drawn?, for what purpose?, what are you trying to achieve?

          Why can you not simply use an existing icon in jpg/png/svg format?

          M Offline
          M Offline
          Muktha PM
          wrote on 21 Jun 2022, 12:07 last edited by
          #4

          @Markkyboy To show the network strength, in jpg or with any image icons, we cannot show the network strength.

          N 1 Reply Last reply 21 Jun 2022, 13:08
          0
          • M Muktha PM
            21 Jun 2022, 12:07

            @Markkyboy To show the network strength, in jpg or with any image icons, we cannot show the network strength.

            N Offline
            N Offline
            ndias
            wrote on 21 Jun 2022, 13:08 last edited by
            #5

            @Muktha-PM said in How to draw "WiFi icon" using QML:

            @Markkyboy To show the network strength, in jpg or with any image icons, we cannot show the network strength.

            Hi @Muktha-PM ,
            You can change the image source property according to the network strength:
            cb28a74a-23c6-470e-af58-825bea828106-image.png

            1 Reply Last reply
            2
            • N ndias
              17 Jun 2022, 09:34

              Hi @Muktha-PM,

              As @Markkyboy metioned before you can use a svg or png format to draw a WiFi icon. If you want draw it you can use shapepath to do it.

              You can find an simple draft below:

              import QtQuick
              import QtQuick.Shapes
              
              Item {
                  id: wifiIcon
              
                  width: parent.width < parent.height ? parent.width : parent.height
                  height: width
                  anchors.centerIn: parent
              
                  Rectangle {
                      anchors.horizontalCenter: wifiIcon.horizontalCenter
                      anchors.bottom: wifiIcon.bottom
                      
              
                      // Set size and corner radius to define a circle
                      width: wifiIcon.width/6
                      height: wifiIcon.height/6
                      radius: width/2
                      
                      color: "#4EC5F1"
                      //border.color: "black"
                      //border.width: 1
                  }
              
                  Shape {
                      ShapePath {
                          fillColor: "transparent"
                          strokeColor: "#4EC5F1"
                          strokeWidth: wifiIcon.height/8
                          capStyle: ShapePath.RoundCap
                          PathAngleArc {
                              centerX: wifiIcon.height / 2
                              centerY: wifiIcon.width / 4 + wifiIcon.width / 4
                              radiusX: wifiIcon.width < wifiIcon.height ? wifiIcon.width/2 - wifiIcon.height/8 : wifiIcon.height/2 - wifiIcon.height/8
                              radiusY: radiusX
                              startAngle: 200
                              sweepAngle: 140
                          }
                      }
              
                      ShapePath {
                          fillColor: "transparent"
                          strokeColor: "#4EC5F1"
                          strokeWidth: wifiIcon.height/8
                          capStyle: ShapePath.RoundCap
                          PathAngleArc {
                              centerX: wifiIcon.height / 2
                              centerY: wifiIcon.width / 3 + wifiIcon.width / 4
                              radiusX: wifiIcon.width < wifiIcon.height ? wifiIcon.width/3 - wifiIcon.height/8 : wifiIcon.height/3 - wifiIcon.height/8
                              radiusY: radiusX
                              startAngle: 200
                              sweepAngle: 140
                          }
                      }
              
                      ShapePath {
                          fillColor: "transparent"
                          strokeColor: "#4EC5F1"
                          strokeWidth: wifiIcon.height/8
                          capStyle: ShapePath.RoundCap
                          PathAngleArc {
                              centerX: wifiIcon.height / 2
                              centerY: wifiIcon.width / 2 + wifiIcon.width / 4
                              radiusX: wifiIcon.width < wifiIcon.height ? wifiIcon.width/4 - wifiIcon.height/8 : wifiIcon.height/4 - wifiIcon.height/8
                              radiusY: radiusX
                              startAngle: 200
                              sweepAngle: 140
                          }
                      }
                  }
              }
              

              Regards

              M Offline
              M Offline
              Muktha PM
              wrote on 29 Jun 2022, 06:31 last edited by
              #6

              @ndias Thank you

              1 Reply Last reply
              1

              • Login

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