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. Set width of widget such that QScrollBar isn't visible
Qt 6.11 is out! See what's new in the release blog

Set width of widget such that QScrollBar isn't visible

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 707 Views 1 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.
  • D Offline
    D Offline
    DevUt
    wrote on last edited by
    #1

    Hello, I'm pretty new to this I'm hoping I'm posting in the right place on the forum.

    I have a QDialog which contains a QTabWidget inside a QVBoxLayout.

    That QTabWidget has a tab which inherits from QScrollArea.

    When I open the Dialog it shows up something like this,

    Settings Dialog on opening

    My desire goal is to have it something like this on opening the Dialog

    Desired dialog

    i.e The horizontal scrollbar shouldn't be visible at start but the vertical maybe visible.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Might be a silly question but why have a QScrollArea if you do not want to use its features ?

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

      D 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi and welcome to devnet,

        Might be a silly question but why have a QScrollArea if you do not want to use its features ?

        D Offline
        D Offline
        DevUt
        wrote on last edited by DevUt
        #3

        @SGaist

        Hey thanks for response. Sorry I wasn't able to express my concern properly.

        The number of widgets in the QGridLayout is dynamic so the vertical scrollbar should be always visible.
        I need scrollbar both horizontal and vertical as user may want to resize the window. The grid only has 2 columns and in start I want it to be visible without needing a horizontal scrollbar. If the user wants they can resize.

        1 Reply Last reply
        0
        • Axel SpoerlA Offline
          Axel SpoerlA Offline
          Axel Spoerl
          Moderators
          wrote on last edited by
          #4

          Have a look at this to read about Qt's size policy options.
          In short, provided that the dialog's layouts and widgets are configured correctly, ỳourDialog->sizeHint() will tell you how wide and high it wants to be without having to use scroll bars. If the vertical and horizontal size policies are both "preferred", the dialog will always start with the QSize given by sizeHint().
          If I read you correctly, you want to set a fixed width to whatever yourDialog->sizeHint().width() is.
          So you set your horizontal size policy to "fixed", assign the fixed size and set the vertical size policy to "preferred" which will allow the user to change the height, but not the width.

          Software Engineer
          The Qt Company, Oslo

          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