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. How to remove a border around QStatusBar ?
Qt 6.11 is out! See what's new in the release blog

How to remove a border around QStatusBar ?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 4.4k Views
  • 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.
  • A Offline
    A Offline
    andulek
    wrote on last edited by
    #1

    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:

    ui->statusBar->setContentsMargins(0,0,0,0);
    ui->statusBar->layout()->setContentsMargins(0,0,0,0);
    ui->statusBar->layout()->setSpacing(0);
    

    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...

    IMAGE

    raven-worxR 1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A andulek

        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:

        ui->statusBar->setContentsMargins(0,0,0,0);
        ui->statusBar->layout()->setContentsMargins(0,0,0,0);
        ui->statusBar->layout()->setSpacing(0);
        

        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...

        IMAGE

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        @andulek
        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

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andulek
          wrote on last edited by
          #4

          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...

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andulek
            wrote on last edited by
            #5

            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);
            
                statusLayout->setContentsMargins(0,0,0,0);
                statusLayout->addWidget(statusBar);
            
                statusBar->show();
            

            that's it! :)

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved