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. Screen resolution and scalability
Qt 6.11 is out! See what's new in the release blog

Screen resolution and scalability

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 7.6k 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.
  • E Offline
    E Offline
    Edward_Abdelsayed
    wrote on last edited by
    #1

    Hi all,

    I'm new here and very excited to join you guys, i wanted to know if there is a way to scale or set aspect ratios to scale my window with
    different screen sizes like the 15, 10 and 7 inches screens without having to write one for each size of screens??

    mrjjM 1 Reply Last reply
    0
    • E Edward_Abdelsayed

      Hi all,

      I'm new here and very excited to join you guys, i wanted to know if there is a way to scale or set aspect ratios to scale my window with
      different screen sizes like the 15, 10 and 7 inches screens without having to write one for each size of screens??

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      @Edward_Abdelsayed
      Hi and welcome :)
      To make widgets automatically adjust size , you use layouts.
      http://doc.qt.io/qt-5/layout.html

      You can do it visually in Designer
      http://doc.qt.io/qt-5/designer-layouts.html

      Overall, you define how they should scale. like minimum size and max size etc.
      It takes a little bit to learn, but then you get scaling almost free.

      1 Reply Last reply
      1
      • E Offline
        E Offline
        Edward_Abdelsayed
        wrote on last edited by
        #3

        Thank you @mrjj is there a way to do it in Qt 4

        mrjjM 1 Reply Last reply
        0
        • E Edward_Abdelsayed

          Thank you @mrjj is there a way to do it in Qt 4

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @Edward_Abdelsayed
          Hi
          Yes its 100% the same :)
          http://doc.qt.io/qt-4.8/designer-layouts.html

          R 1 Reply Last reply
          1
          • mrjjM mrjj

            @Edward_Abdelsayed
            Hi
            Yes its 100% the same :)
            http://doc.qt.io/qt-4.8/designer-layouts.html

            R Offline
            R Offline
            RingAndReed
            wrote on last edited by RingAndReed
            #5

            @mrjj Is this solution applicable in the following context?
            I made a Qt C++ Desktop application for Windows 10 (Visual Studio 2015): on the initial computer (2880x1800) the layout is very nice but for the second (1680x1050) all is wonky:

            • spacing between widgets is all wrong
            • tables put lots of extra white space after columns (only 3 input columns)
            • buttons at bottom of window no longer show-up...

            Thanks.!
            0_1502382410539_goodSize.png

            1_1502382410539_sizeOutOfProportion.PNG

            mrjjM 1 Reply Last reply
            0
            • R RingAndReed

              @mrjj Is this solution applicable in the following context?
              I made a Qt C++ Desktop application for Windows 10 (Visual Studio 2015): on the initial computer (2880x1800) the layout is very nice but for the second (1680x1050) all is wonky:

              • spacing between widgets is all wrong
              • tables put lots of extra white space after columns (only 3 input columns)
              • buttons at bottom of window no longer show-up...

              Thanks.!
              0_1502382410539_goodSize.png

              1_1502382410539_sizeOutOfProportion.PNG

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @RingAndReed
              Yes, sounds like you need a layout.
              Did you use any layout?

              Update:
              for the table , there is a function to make it use all space for the cells. its not layout related.

              view->horizontalHeader()->setStretchLastSection(true) to make the last column expand to free space.
              view->horizontalHeader()->setResizeMode(QHeaderView::Stretch) to give columns the same width.

              R 1 Reply Last reply
              2
              • mrjjM mrjj

                @RingAndReed
                Yes, sounds like you need a layout.
                Did you use any layout?

                Update:
                for the table , there is a function to make it use all space for the cells. its not layout related.

                view->horizontalHeader()->setStretchLastSection(true) to make the last column expand to free space.
                view->horizontalHeader()->setResizeMode(QHeaderView::Stretch) to give columns the same width.

                R Offline
                R Offline
                RingAndReed
                wrote on last edited by
                #7

                @mrjj : no I did not ... I am very new to Qt C++.

                I think, you answered before I edited my question (added 2 screenshots).

                I will try the layouts as you suggest. Right now, I did not even account for scrollbars etc.

                mrjjM 1 Reply Last reply
                0
                • R RingAndReed

                  @mrjj : no I did not ... I am very new to Qt C++.

                  I think, you answered before I edited my question (added 2 screenshots).

                  I will try the layouts as you suggest. Right now, I did not even account for scrollbars etc.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #8

                  @RingAndReed
                  Then you surely need at least one to make them fit mainwindow.
                  Also note the update regarding the table.

                  Note2: in Designer, it shows layouts with the buttons/widgets in the left side.
                  Those are not the ones to use :)

                  Right click and use the layout menu to apply layout.

                  Its a little bit hard at first so prepare to practice a bit.
                  There are many videos of using them.

                  Note3:
                  To control if stuff get to small or too big,, you use
                  the MinimumSize and MaximumSize. Layout respect that.
                  You can also set policy telling if u want to be small as possible, use all space or how it should be.

                  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