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. How to resize the application with different screen sizes?
QtWS25 Last Chance

How to resize the application with different screen sizes?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 3.0k 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.
  • Z Offline
    Z Offline
    zhmh
    wrote on 1 Jun 2019, 05:35 last edited by
    #1

    I want to automatically resize my application with different screen sizes, I have a StackedWidget in the app,
    From this link I assign grid layout to the central widget. , Which has Automatic resizing with different screen size,but content of it doesn't resize
    0_1559367264899_Screenshot from 2019-06-01 09-45-12.png

    I add the grid layout on each page of stackWidget but the button,lineEdit,.... get too wide and
    Cannot resize or change location of it
    0_1559367298504_Screenshot from 2019-06-01 10-01-24.png

    With assign grid layout on central widget all content of it should be get layout?
    How do I assign layouts to pages that can resize the qlineEdit, button ...?!

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 1 Jun 2019, 06:08 last edited by mrjj 6 Jan 2019, 06:13
      #2

      Hi
      You are doing it right,
      however, both QLineEdit and QPushButton have Fixed policy as default
      alt text
      preventing them from growing/use all space.

      alt text

      If you do
      alt text
      then they grow
      alt text

      Anyway, you need both layout on CentralWidget to size the stackedwidget and then
      on each page, you also need a layout. (which you seem to do )

      Z 1 Reply Last reply 1 Jun 2019, 09:31
      2
      • M mrjj
        1 Jun 2019, 06:08

        Hi
        You are doing it right,
        however, both QLineEdit and QPushButton have Fixed policy as default
        alt text
        preventing them from growing/use all space.

        alt text

        If you do
        alt text
        then they grow
        alt text

        Anyway, you need both layout on CentralWidget to size the stackedwidget and then
        on each page, you also need a layout. (which you seem to do )

        Z Offline
        Z Offline
        zhmh
        wrote on 1 Jun 2019, 09:31 last edited by
        #3

        @mrjj tnx

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          zhmh
          wrote on 12 Jun 2019, 18:34 last edited by zhmh 6 Dec 2019, 19:16
          #4

          When I using buttons, lineEdits, labels, comboBox on a page, for example, I use 30 items in grid layout and run the program with xcb platform, in raspberry pi with a 800 x 480 display(5inch) , This will cause the app's page to be dragged down and right and not everything show completely the window minimize,closer button is not specified. But When I use fewer items, it's okay,
          I need to use 30 items in one page how can I fixed the program size ?
          I use this in main.cpp:

          QRect rec = QApplication::desktop()->screenGeometry();
             int height1 = rec.height();
             int width1 = rec.width();
             w.resize(width1,height1);
          

          and this in mainWindow.cpp:

          this->setStyleSheet(
                          "#centralWidget { "
                          " border-image: url(:/new/prefix1/Untitled-7.jpg) 0 0 0 0 stretch stretch;"
                          "}");
          
          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 12 Jun 2019, 19:01 last edited by
            #5

            Hi,

            Why not use showFullScreen directly ?

            What are these 30 items ? It's quite a lot on a small screen.

            You might want to consider using QScrollArea to allow your user to scroll up and down to see your widgets.

            Depending on your application, you might wan to break down your UI in smaller elements.

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

            Z 1 Reply Last reply 13 Jun 2019, 15:09
            2
            • S SGaist
              12 Jun 2019, 19:01

              Hi,

              Why not use showFullScreen directly ?

              What are these 30 items ? It's quite a lot on a small screen.

              You might want to consider using QScrollArea to allow your user to scroll up and down to see your widgets.

              Depending on your application, you might wan to break down your UI in smaller elements.

              Z Offline
              Z Offline
              zhmh
              wrote on 13 Jun 2019, 15:09 last edited by
              #6
              This post is deleted!
              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