Nominate our 2022 Qt Champions!

QToolBox and scrollbars taking the extra space ?

  • I am trying to get rid of a QScrollBar in a QToolbox because they (even not visible) take the space hence the QToolButton(s) do not expand horizontally to the full extent. I have tried to apply the style sheets like:

    QScrollBar:horizontal {
    height: 0px;
    width: 0px;
    QScrollBar:vertical {
    height: 0px;
    width: 0px;

    Did not help. Is there a way to use the scrollbar(s) space for the QToolButtons ?

  • Lifetime Qt Champion

    In win 7. Qt 5.5. setting your stylesheet on the
    QToolbox, does remove the scrollbar and allow me to
    let the widget go all way to the edge.

  • @mrjj ,

    I am running a Windows 7 and Qt version 5.5.0/5.5/mingw492_32 libs ,

    hmm, very strange.


    just notice a gap on the left side of the QToolButton on the provided picture ... is there a way to remove that one ?

  • Lifetime Qt Champion

    Hmm does seem very close to my version.

    • just notice a gap on the left side of the QToolButton on the provided picture
      Yes that is just the layouts "layoutLeftMargin" that default has 9. if u set to 0
      its aligned with left side.

    maybe u can try my test project and tell me if does the same for you

    Maybe you use another layout or something else so it seems to work for me and not for you.
    Maybe my sample is not working as u want it to. just looking like it :)

  • @mrjj ,

    Thanks so much , your example works fine on my pc too. So it must be something with the layout properties in my project.

    Strange, cause I checked all the buttons, and they are expanding with the stretch set above zero to take the extra space.

    But it is important for me to know that is workable.

  • Lifetime Qt Champion

    Ok that is good news.
    Its probably just something simple then.

    I set the layoutMargins (left and right ) on the layout i put inside
    QToolBox "page"/area.
    and then ur stylesheet.
    (just for the record)

  • @mrjj ,

    yes , you were right, the, I needed to LayoutStretch of docket widget to 1,1,1,1,1,1,1 and that has solved the expanding of the buttons. ( I thought the QButton size policy was enough , but a docket widget needed the stretch to expand the buttons).

    Thank you so much.

Log in to reply