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. Making a circular profile picture in QtCreator
QtWS25 Last Chance

Making a circular profile picture in QtCreator

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
10 Posts 6 Posters 927 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.
  • G Offline
    G Offline
    Gilberrt
    wrote on last edited by
    #1

    I'm trying to develop a project and I have to make a profile picture that shows in a circle like the ones you normally see everywhere on a profile. Someone help me do that.
    I knwo how to make a circle by making the radius of a rectangle half the width, my problem is fitting an image and clipping it so it doesn't appear outside the circle. How do I do that?

    MarkkyboyM Ronel_qtmasterR 2 Replies Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      This might serve as good base.

      Don't forget to credit the author.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      mzimmersM 1 Reply Last reply
      1
      • G Gilberrt

        I'm trying to develop a project and I have to make a profile picture that shows in a circle like the ones you normally see everywhere on a profile. Someone help me do that.
        I knwo how to make a circle by making the radius of a rectangle half the width, my problem is fitting an image and clipping it so it doesn't appear outside the circle. How do I do that?

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

        @Gilberrt - out of curiosity, which version of Qt are you using?, Qt5 or Qt6?

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

        I live by the sea, not in it.

        G 1 Reply Last reply
        0
        • G Gilberrt

          I'm trying to develop a project and I have to make a profile picture that shows in a circle like the ones you normally see everywhere on a profile. Someone help me do that.
          I knwo how to make a circle by making the radius of a rectangle half the width, my problem is fitting an image and clipping it so it doesn't appear outside the circle. How do I do that?

          Ronel_qtmasterR Offline
          Ronel_qtmasterR Offline
          Ronel_qtmaster
          wrote on last edited by Ronel_qtmaster
          #4

          @Gilberrt maybe this can help?

          Item {
             id:circularImage
              anchors.fill: parent
              Rectangle
              {
                  width: 500
                  height: 500
                  color: "#a2ecf5"
                  radius:  width/2
                  anchors.centerIn: parent
          
                  Image {
                      width: 350
                      height: 350
                      source: "image.png"
                      anchors.horizontalCenter: parent.horizontalCenter
                      anchors.verticalCenter: parent.verticalCenter
                  }
          
                 }
           }
          
          G 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi and welcome to devnet,

            This might serve as good base.

            Don't forget to credit the author.

            mzimmersM Offline
            mzimmersM Offline
            mzimmers
            wrote on last edited by
            #5

            @SGaist just as a side note, the solution you referenced depends on QtGraphicalEffects 1.0 and so probably won't work in Qt 6. This seems to be the modern equivalent.

            SGaistS ndiasN 2 Replies Last reply
            2
            • mzimmersM mzimmers

              @SGaist just as a side note, the solution you referenced depends on QtGraphicalEffects 1.0 and so probably won't work in Qt 6. This seems to be the modern equivalent.

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @mzimmers good point ! Thanks for the updated version.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • mzimmersM mzimmers

                @SGaist just as a side note, the solution you referenced depends on QtGraphicalEffects 1.0 and so probably won't work in Qt 6. This seems to be the modern equivalent.

                ndiasN Offline
                ndiasN Offline
                ndias
                wrote on last edited by
                #7

                Solution @mzimmers reported will work.

                Maybe I will recomend to set fillMode to PreserveAspectCrop to preserve aspect ratio of not square images.

                import QtQuick.Effects will be required.

                1 Reply Last reply
                0
                • MarkkyboyM Markkyboy

                  @Gilberrt - out of curiosity, which version of Qt are you using?, Qt5 or Qt6?

                  G Offline
                  G Offline
                  Gilberrt
                  wrote on last edited by
                  #8

                  @Markkyboy It's been long.....I'm using Qt Version 6.4

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Another solution is provided here.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • Ronel_qtmasterR Ronel_qtmaster

                      @Gilberrt maybe this can help?

                      Item {
                         id:circularImage
                          anchors.fill: parent
                          Rectangle
                          {
                              width: 500
                              height: 500
                              color: "#a2ecf5"
                              radius:  width/2
                              anchors.centerIn: parent
                      
                              Image {
                                  width: 350
                                  height: 350
                                  source: "image.png"
                                  anchors.horizontalCenter: parent.horizontalCenter
                                  anchors.verticalCenter: parent.verticalCenter
                              }
                      
                             }
                       }
                      
                      G Offline
                      G Offline
                      Gilberrt
                      wrote on last edited by
                      #10

                      @Ronel_qtmaster Thanks for answering

                      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