Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. image size, position and aspect ratio

image size, position and aspect ratio

Scheduled Pinned Locked Moved Solved Mobile and Embedded
8 Posts 3 Posters 2.3k Views 1 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.
  • canellasC Offline
    canellasC Offline
    canellas
    wrote on last edited by canellas
    #1

    Hi!

    I wrote an app using QtWidgets that runs on Android and iPhone.

    In the first window there are 3 images, and I can not, no matter how many ways I tried, to make the images no to loose aspect ratio, as the app runs on a different resolution.

    The images are in QFrame, set using style sheet in the window designer.

    I also searched a lot, and again failed to find a solution.

    Is there a way, in compile time or run time, to do it? I am running out of time, and out of options!

    Thanks!

    1 Reply Last reply
    0
    • canellasC Offline
      canellasC Offline
      canellas
      wrote on last edited by
      #7

      Thanks for your time

      I tried to use layouts, but the aspect ratio of the image was not preserved. Probably I am misusing it. I solved in the old fashioned way: calculating width, height as position.

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

        Hi,

        Why not use QLabel to show these images ?

        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
        1
        • canellasC Offline
          canellasC Offline
          canellas
          wrote on last edited by canellas
          #3

          I am trying that right now, and still can't make it...

          The QLabel is inside a QFrame.

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

            Why the label in the Frame ?

            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
            • canellasC Offline
              canellasC Offline
              canellas
              wrote on last edited by
              #5

              I use QFrame objects to help me positioning widgets. I do not know if it is the best way to do it, but it is the only way I know, so far.

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

                Why not use layouts ?

                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
                1
                • canellasC Offline
                  canellasC Offline
                  canellas
                  wrote on last edited by
                  #7

                  Thanks for your time

                  I tried to use layouts, but the aspect ratio of the image was not preserved. Probably I am misusing it. I solved in the old fashioned way: calculating width, height as position.

                  1 Reply Last reply
                  1
                  • timdayT Offline
                    timdayT Offline
                    timday
                    wrote on last edited by
                    #8

                    Bit late... but I feel compelled to point out that QML's Image element's support for aspect ratio scaling (take your pick of Image.PreserveAspectFit or Image.PreserveAspectCrop) combined with the horizontal and vertical alignment control properties, (if you don't just want the default centering) is absolutely brilliant for creating layouts which adapt to different screen ratios while preserving designers' original intentions about what's lined up with what. Don't know if embedding a QQuickView and a little bit of QML was an option for you though.

                    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