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. Width of QHBoxLayout is restricted in QDialog
QtWS25 Last Chance

Width of QHBoxLayout is restricted in QDialog

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 330 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.
  • M Offline
    M Offline
    makopo
    wrote on last edited by makopo
    #1

    Hello,

    I'am using a QDialog window that opens if a user press a special key or interacts with the menu bar.

    I create a class that inherits QDialog and create a instance of QHBoxLayout. If I use the horizontal layout I can see that the width of the layout is cropped /restricted.

    0cf2878b-99fe-42ae-a6d7-54e51d74cd50-grafik.png

    m_hLayout->addWidget(m_one);
    m_hLayout->addWidget(m_two);
    m_hLayout->addWidget(m_three);
    m_hLayout->addWidget(m_four);
    //m_groupMag->setFixedSize(500, 700); //adding a fixed size shows the button with the full size.
    m_groupMag->setLayout(m_hLayout);
    

    One way to correct this is to set the size of the QWidget that sets the layout to a fixed size. Nevertheless I think that is can not be the correct way.
    If I use the QVBoxLayout there is no problem with any restriction. The elements are shown with the full size vertically.

    The dialog window opens with the showMaximized() function.
    Any idea what the problem is?

    Kind regards.

    jsulmJ 1 Reply Last reply
    0
    • M makopo

      Hello,

      I'am using a QDialog window that opens if a user press a special key or interacts with the menu bar.

      I create a class that inherits QDialog and create a instance of QHBoxLayout. If I use the horizontal layout I can see that the width of the layout is cropped /restricted.

      0cf2878b-99fe-42ae-a6d7-54e51d74cd50-grafik.png

      m_hLayout->addWidget(m_one);
      m_hLayout->addWidget(m_two);
      m_hLayout->addWidget(m_three);
      m_hLayout->addWidget(m_four);
      //m_groupMag->setFixedSize(500, 700); //adding a fixed size shows the button with the full size.
      m_groupMag->setLayout(m_hLayout);
      

      One way to correct this is to set the size of the QWidget that sets the layout to a fixed size. Nevertheless I think that is can not be the correct way.
      If I use the QVBoxLayout there is no problem with any restriction. The elements are shown with the full size vertically.

      The dialog window opens with the showMaximized() function.
      Any idea what the problem is?

      Kind regards.

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

      @makopo said in Width of QHBoxLayout is restricted in QDialog:

      m_groupMag

      Is this widget also in a layout?

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

      M 1 Reply Last reply
      0
      • jsulmJ jsulm

        @makopo said in Width of QHBoxLayout is restricted in QDialog:

        m_groupMag

        Is this widget also in a layout?

        M Offline
        M Offline
        makopo
        wrote on last edited by
        #3

        @jsulm
        No, the widget only sets the layout.

        jsulmJ 1 Reply Last reply
        0
        • M makopo

          @jsulm
          No, the widget only sets the layout.

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

          @makopo Then m_groupMag will not resize or fill free space. Put it also in the layout of its parent.

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

          M 1 Reply Last reply
          1
          • jsulmJ jsulm

            @makopo Then m_groupMag will not resize or fill free space. Put it also in the layout of its parent.

            M Offline
            M Offline
            makopo
            wrote on last edited by
            #5

            @jsulm

            Thank you. I think I missunterstand the Layout Concept of Qt. After removing the widget I got a correct horizontal layout.
            Think I have to study the docs a bit more.

            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