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. QT how to prevent layouts from shrinking when they are empty
QtWS25 Last Chance

QT how to prevent layouts from shrinking when they are empty

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 296 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.
  • L Offline
    L Offline
    lukutis222
    wrote on last edited by lukutis222
    #1

    Hey. I am creating a template look for my application. I have put some layouts just to see how my application is going to look like:
    13415962-0bb4-4d18-af9a-64c5ba9a373a-image.png

    Just to see how my layout is going to look like, I have put labels everywhere, but in my actual application, this information will be dynamically created and custom labels, buttons and etc will be added to layouts.

    For example, this grid layout:
    dfc667c3-40ec-42e9-8d48-b3caa6f39c4f-image.png

    Instead of having textLabel, when the program starts it will be empty. If I delete all the labels the gridlayout will shrink and it becomes difficult to visualise how the application is going to look like:

    1a8d3c97-2d81-47ed-b3e7-46c3380a5af2-image.png

    I hope you understand what I mean. Is there any way to ensure the empty layout does not shrink just so I can visually see how is it going to look like when it gets filled?

    Christian EhrlicherC 1 Reply Last reply
    0
    • L lukutis222

      Hey. I am creating a template look for my application. I have put some layouts just to see how my application is going to look like:
      13415962-0bb4-4d18-af9a-64c5ba9a373a-image.png

      Just to see how my layout is going to look like, I have put labels everywhere, but in my actual application, this information will be dynamically created and custom labels, buttons and etc will be added to layouts.

      For example, this grid layout:
      dfc667c3-40ec-42e9-8d48-b3caa6f39c4f-image.png

      Instead of having textLabel, when the program starts it will be empty. If I delete all the labels the gridlayout will shrink and it becomes difficult to visualise how the application is going to look like:

      1a8d3c97-2d81-47ed-b3e7-46c3380a5af2-image.png

      I hope you understand what I mean. Is there any way to ensure the empty layout does not shrink just so I can visually see how is it going to look like when it gets filled?

      Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Set a minimum size to your labels

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      L 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        Set a minimum size to your labels

        L Offline
        L Offline
        lukutis222
        wrote on last edited by lukutis222
        #3

        @Christian-Ehrlicher
        I placed labels just to keep the layout from shrinking. I have to place something in there (buttons, checkboxes or whatever). This is just so I can visually see how its going to look like when I dynamically fill the grid layout.

        There will not be any widgets (labels) at the start of the application but in mainwindow.ui I would still like to see the layout not shrinked even though there is no widgets inside. Do you know what I mean?

        Christian EhrlicherC JonBJ 2 Replies Last reply
        0
        • L lukutis222

          @Christian-Ehrlicher
          I placed labels just to keep the layout from shrinking. I have to place something in there (buttons, checkboxes or whatever). This is just so I can visually see how its going to look like when I dynamically fill the grid layout.

          There will not be any widgets (labels) at the start of the application but in mainwindow.ui I would still like to see the layout not shrinked even though there is no widgets inside. Do you know what I mean?

          Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @lukutis222 said in QT how to prevent layouts from shrinking when they are empty:

          Do you know what I mean?

          Yes

          Set a minimum size to your labels

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • L lukutis222

            @Christian-Ehrlicher
            I placed labels just to keep the layout from shrinking. I have to place something in there (buttons, checkboxes or whatever). This is just so I can visually see how its going to look like when I dynamically fill the grid layout.

            There will not be any widgets (labels) at the start of the application but in mainwindow.ui I would still like to see the layout not shrinked even though there is no widgets inside. Do you know what I mean?

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

            @lukutis222
            As @Christian-Ehrlicher says, put a QLabel or a QWidget in with a minimum size to see what it will look like at design time. Then if necessary start by removing/replacing these widgets with whatever you really want immediately after calling setupUi() at runtime.

            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