Important: Please read the Qt Code of Conduct -

Double scrollbars in Qtoolbox

  • I use a toolbox and I push in QTextEdit as items with the method addItem.

    So one open toolbox slot contains a QTextEdit and for some reason already a scrollbar. This scrollbar is not neccessary since the QTextEdit automatically adds a scroll bar a soon as the text goes beyond the open toolbox slot. The result is double scroll bars, one on the toolbox item that is always visible one that is added by the textedit. How can I disable the default toolbox-items-scrollbars and only let the textedit add a scroller?


  • Lifetime Qt Champion


    It's just a hack idea (not tested)

    Try to search for QScrollArea children of your QToolBox and set the horizontal and vertical scroll bar policy to Qt::ScrollBarAlwaysOff

  • Maybe you should search for QAbstractScrollArea instead, since that's where these settings reside. Just to be on the safe side.

    A different idea would be that you deactivate the scrollbars of the QTextEdit (same syntax, it's a QAbstractScrollArea itself) and allow it to freely resize to its contents - the parent will provide scrollbars if necessary.
    Either you do this via settings like QWidget::setSizePolicy or by reimplementing one of its functions (update() might be overkill, but I can't think of a better one right now).

    None of these I have tested on my own yet, but I am sure there is a somewhat pretty solution to be found.

Log in to reply