Important: Please read the Qt Code of Conduct -

How to remove a border around QStatusBar ?

  • Hello, my first ever post here! :)

    Basically i have a requirement to make left-side qtoolbar to stretch down to window bottom.
    The problem is, that we use a QStatusBar at the same time, which occupies bottom space and prevents qtoolbar from stretching to the bottom.

    i thought of a simple hack:

    Add a Widget to QStatusBar, set the background and width same as QToolBar, and make an illusion that qtoolbar is down to the bottom :)

    What makes a problem to achieve this, that qstatusbar has a border around itself...
    Tried to play around with stylesheets, setting "QStatusBar { border: none; } did not help.

    Also tried these:


    still no use.. please see attached picture,
    i made a green background of qstatusbar for better visual understanding of the problem,
    ideally i need inside QWidget to expand and fill whole space, visually "connecting" to QToolBar...


  • Lifetime Qt Champion

    This is quite unusual UI design. Are you sure you want to do it like this? Usually a status bar occupies the whole bottom part of a window. It would irritate user if it would be different in your application.

  • Moderators

    not really. Actually you would need to set the margins for the statusbar-layoutitem in the parent's (main window) layout. Which is of the (non-public) type QMainWindowLayout

  • hmm, so as i understand there is no way of getting into QMainWindowLayout ... bad...

    maybe there is possibility to make QStatusBar smaller and QToolBar down to the bottom of QMainWIndow?

    as a last resort i see removing QStatusBar completely and adding one more QToolBar at the bottom...

  • Just in case someone needs it:

    In QtDesigner:

    • Remove QStatusBar completely (QToolBar will expand to the bottom after doing this)
    • Add empty widget into QCentralWidget at the bottom of it, and stretch it in the layout from left to right
      in my example it got automatic name "widget_6";
    • change QCentralWidget's layout margins: left: 0, bottom: 0, right: 0;

    then in your code, in MainWindow constructor:

        QStatusBar *statusBar = new QStatusBar(ui->widget_6);
        QGridLayout *statusLayout = new QGridLayout(ui->widget_6);

    that's it! :)

Log in to reply