Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Centering an uploaded photo after rounding it
Forum Updated to NodeBB v4.3 + New Features

Centering an uploaded photo after rounding it

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 3 Posters 977 Views 2 Watching
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Hi,

    What are the exact dimensions of your picture ?

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

    T 1 Reply Last reply
    0
    • SGaistS SGaist

      Hi,

      What are the exact dimensions of your picture ?

      T Offline
      T Offline
      Tamfub
      wrote on last edited by
      #5

      @SGaist Hi, it's 200x200 pixels.

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

        With the rounded part in its center ?

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

        T 1 Reply Last reply
        0
        • SGaistS SGaist

          With the rounded part in its center ?

          T Offline
          T Offline
          Tamfub
          wrote on last edited by Tamfub
          #7

          @SGaist

          The photo is this one, and I want it round (just ignore the fact that a circle is inside it)

          download.png

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

            I saw your error, you changed the alignement.

            You need to use Qt::AlignCenter

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

            T 1 Reply Last reply
            0
            • SGaistS SGaist

              I saw your error, you changed the alignement.

              You need to use Qt::AlignCenter

              T Offline
              T Offline
              Tamfub
              wrote on last edited by
              #9

              @SGaist I tried:

              ui->photo_label->setAlignment(Qt::AlignCenter);
              

              but the result is:
              Screenshot_1.png

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

                One issue I can see is that you are are calling size in your constructor. At this stage, the widget does not have any size yet. But also, why your QMainWindow size to create your target pixmap ?

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

                T 1 Reply Last reply
                1
                • SGaistS SGaist

                  One issue I can see is that you are are calling size in your constructor. At this stage, the widget does not have any size yet. But also, why your QMainWindow size to create your target pixmap ?

                  T Offline
                  T Offline
                  Tamfub
                  wrote on last edited by Tamfub
                  #11

                  @SGaist Ok, I replaced

                  QPixmap target = QPixmap(size());
                  

                  with

                  QPixmap target = QPixmap(400, 400);
                  

                  and now it gives me
                  Screenshot_2.png

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

                    Looks like you are good, aren't you ?

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

                    T 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      Looks like you are good, aren't you ?

                      T Offline
                      T Offline
                      Tamfub
                      wrote on last edited by Tamfub
                      #13

                      @SGaist Yes, but I also toyed with the position/alignment settings in the .ui designer and got it to work :)

                      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