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. Uniform widget scaling while window sizing...

Uniform widget scaling while window sizing...

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 778 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.
  • 1 Offline
    1 Offline
    1XU7
    wrote on last edited by
    #1

    Hello, is there a way to scale up uniformly all my widgets when i resize my window keeping aspect ratio?

    b3fe8569-8062-4cd3-966e-d94eff52405b-image.png

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

      Hi,

      Are you using 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 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi,

        Are you using layouts ?

        1 Offline
        1 Offline
        1XU7
        wrote on last edited by
        #3

        @SGaist Hi... i could if necessary...

        jsulmJ 1 Reply Last reply
        0
        • 1 1XU7

          @SGaist Hi... i could if necessary...

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @1XU7 Well, you should. Why would you do placing and resizing widgets manually if you can simply use layouts instead?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 1 Reply Last reply
          2
          • jsulmJ jsulm

            @1XU7 Well, you should. Why would you do placing and resizing widgets manually if you can simply use layouts instead?

            1 Offline
            1 Offline
            1XU7
            wrote on last edited by
            #5

            @jsulm hi, i dont have problems using layouts.. i like to use them.. just want to get the effect of uniform scaling keeping aspect ratio like the image... my goal is to make my UI the most accessibility possible so when user resizes window it will act somehow a magnifier... layouts is ok for keeping widgets in position.. but i could not find a way to scale them up or down while resizing window...

            i could use QResizeEvent and manually scale them, but that is a bit tricky to get them very well arranged after growing.. so i was wondering if there is another way to make it..

            thanks.

            jsulmJ JonBJ 2 Replies Last reply
            0
            • 1 1XU7

              @jsulm hi, i dont have problems using layouts.. i like to use them.. just want to get the effect of uniform scaling keeping aspect ratio like the image... my goal is to make my UI the most accessibility possible so when user resizes window it will act somehow a magnifier... layouts is ok for keeping widgets in position.. but i could not find a way to scale them up or down while resizing window...

              i could use QResizeEvent and manually scale them, but that is a bit tricky to get them very well arranged after growing.. so i was wondering if there is another way to make it..

              thanks.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @1XU7 You should take a look at:

              • https://doc.qt.io/qt-6/qwidget.html#sizePolicy-prop
              • https://doc.qt.io/qt-6/qwidget.html#sizeHint-prop
              • https://doc.qt.io/qt-6/qwidget.html#sizeIncrement-prop
              • set*Stretch methods like https://doc.qt.io/qt-6/qgridlayout.html#setColumnStretch

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2
              • 1 1XU7

                @jsulm hi, i dont have problems using layouts.. i like to use them.. just want to get the effect of uniform scaling keeping aspect ratio like the image... my goal is to make my UI the most accessibility possible so when user resizes window it will act somehow a magnifier... layouts is ok for keeping widgets in position.. but i could not find a way to scale them up or down while resizing window...

                i could use QResizeEvent and manually scale them, but that is a bit tricky to get them very well arranged after growing.. so i was wondering if there is another way to make it..

                thanks.

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @1XU7
                Layouts are indeed the way to get Qt to reposition/resize your widgets, and you should read @jsulm's links and start with https://doc.qt.io/qt-6/layout.html too.

                Just so you are aware: this will do some of what you show in your picture but not necessarily all. For example, you can arrange for QPushButtons to be allowed to grow both horizontally and vertically if you wish, and the button will grow/shrink. But it won't change the font size like you show, you would have to do that yourself. And although a QLabel with a picture can grow I'm not sure that the picture will automatically rescale to fit the new size, you may have to do that yourself.

                1 Reply Last reply
                3

                • Login

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