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?
Forum Updated to NodeBB v4.3 + New Features

How to resize the application with different screen sizes?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 3.2k 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.
  • zhmhZ Offline
    zhmhZ Offline
    zhmh
    wrote on 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
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #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 )

      zhmhZ 1 Reply Last reply
      2
      • mrjjM mrjj

        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 )

        zhmhZ Offline
        zhmhZ Offline
        zhmh
        wrote on last edited by
        #3

        @mrjj tnx

        1 Reply Last reply
        0
        • zhmhZ Offline
          zhmhZ Offline
          zhmh
          wrote on last edited by zhmh
          #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
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on 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

            zhmhZ 1 Reply Last reply
            2
            • SGaistS SGaist

              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.

              zhmhZ Offline
              zhmhZ Offline
              zhmh
              wrote on 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