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. Prevent horizontal spacer from taking up widget's space
Forum Updated to NodeBB v4.3 + New Features

Prevent horizontal spacer from taking up widget's space

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

    Output without spacer:
    56117130-46a1-4d91-88d0-26d7b0acdf84-image.png

    Output with spacer:
    20f135f1-5c9d-4f9c-9313-07cb61f59174-image.png

    I want all 3 buttons to be visible even while using horizontal spacers on both sides of the buttons' widget.

    Size Policies:
    Left Spacer: Minimum Expanding
    Right Spacer: Minimum Expanding
    Buttons' Widget: Expanding

    I have tried different combination of policies. I want to know if a property exists to prevent the spacers from taking up the space of the widget.

    jsulmJ 1 Reply Last reply
    0
    • S Offline
      S Offline
      Shrishashank
      wrote on last edited by
      #2

      // Assuming a horizontal layout with: [Left Spacer] [Buttons Widget] [Right Spacer]

      // Set a minimum width for the buttons widget so it doesn't get squished
      buttonsWidget.setMinimumWidth(preferredWidth);

      // You can also set stretch factors if your layout manager supports it
      layout.setStretchFactor(leftSpacer, 1);
      // Higher priority for space
      layout.setStretchFactor(buttonsWidget, 10);
      layout.setStretchFactor(rightSpacer, 1);

      SHRISHASHANK S K

      1 Reply Last reply
      0
      • S shreya_agrawal

        Output without spacer:
        56117130-46a1-4d91-88d0-26d7b0acdf84-image.png

        Output with spacer:
        20f135f1-5c9d-4f9c-9313-07cb61f59174-image.png

        I want all 3 buttons to be visible even while using horizontal spacers on both sides of the buttons' widget.

        Size Policies:
        Left Spacer: Minimum Expanding
        Right Spacer: Minimum Expanding
        Buttons' Widget: Expanding

        I have tried different combination of policies. I want to know if a property exists to prevent the spacers from taking up the space of the widget.

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

        @shreya_agrawal Please provide more information (ideally also code): Where exactly did you put the spacers?

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

        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