Important: Please read the Qt Code of Conduct -

Add space after ScrollBar?

  • I have a QScrollArea with a QGridLayout set via setLayout(). This scroll area is then added to a QMdiSubWindow.

    I have an animation that hides this sub window on a QEvent::Leave, and the problem is that the vertical scroll bar of the QScrollArea is too close to the right edge of the QMdiSubWindow which I am filtering for leave events.

    I need to add a sort of "buffer" region between my vertical scroll bar and the end of the sub window such that the hiding function is not as sensitive.

    Not sure what the best way to do this is... any ideas?

    What I tried was increasing the width of the sub window, also trying to set margins for the grid layout to add space to the right edge, adding a spacer item etc. but unfortunately none of this worked.

  • Moderators

    try the following:

    QMargins m = scrollArea->getContentsMargins();
    m.setRight( m.right() + 10 );
    scrollArea->setContentsMargins( m );

Log in to reply