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 add second status bar and display it above the first one?

How to add second status bar and display it above the first one?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 485 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
    Anonymous_Banned275
    wrote on 11 Apr 2024, 18:06 last edited by Anonymous_Banned275 4 Nov 2024, 18:08
    #1

    This TEST (!) code is an attempt to add second status bar to QMainWindow.

    I cannot figure out how to locate / display it.
    I like to have it ABOVE the current , default, status bar.

    Do I have to calculate the size of current, default bar and then set the second one accordingly ? (yes/ no answer would be sufficient)

    Will such calculation " make room" in the layout so BOTH status bars can be shown SAME TIME ?

    Do I have to "resize" the main part of the layout?

    PS
    when I use
    statusBar()->addWidget(secondstatusbar);

    the second bar takes place of the original bar.
    That MAY work , but not what I need.

               m_ui->setupUi(this);
                // add secondstatusbar here ??
    
                //Add
                QStatusBar *secondstatusbar = new QStatusBar(this);
                this->layout()->addWidget(secondstatusbar);
                text =  " A TEST secondstatusbar !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" ;
                secondstatusbar->showMessage(text);
    
                secondstatusbar->setBaseSize(4000,4000);
                secondstatusbar->move(0,600);
    
               statusBar()->addWidget(secondstatusbar);
               
                       
                       
    
    A 1 Reply Last reply 13 Apr 2024, 14:20
    0
    • A Anonymous_Banned275
      11 Apr 2024, 18:06

      This TEST (!) code is an attempt to add second status bar to QMainWindow.

      I cannot figure out how to locate / display it.
      I like to have it ABOVE the current , default, status bar.

      Do I have to calculate the size of current, default bar and then set the second one accordingly ? (yes/ no answer would be sufficient)

      Will such calculation " make room" in the layout so BOTH status bars can be shown SAME TIME ?

      Do I have to "resize" the main part of the layout?

      PS
      when I use
      statusBar()->addWidget(secondstatusbar);

      the second bar takes place of the original bar.
      That MAY work , but not what I need.

                 m_ui->setupUi(this);
                  // add secondstatusbar here ??
      
                  //Add
                  QStatusBar *secondstatusbar = new QStatusBar(this);
                  this->layout()->addWidget(secondstatusbar);
                  text =  " A TEST secondstatusbar !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" ;
                  secondstatusbar->showMessage(text);
      
                  secondstatusbar->setBaseSize(4000,4000);
                  secondstatusbar->move(0,600);
      
                 statusBar()->addWidget(secondstatusbar);
                 
                         
                         
      
      A Offline
      A Offline
      Axel Spoerl
      Moderators
      wrote on 13 Apr 2024, 14:20 last edited by
      #2

      @AnneRanch
      The only obvious mistake is the last line statusBar()->addWidget(secondstatusbar);
      Since you show only parts of your code, we don't know what thisis. If it inherits from QMainWindow, don't add the second status bar to the main window layout. Add a layout to your central widget, add a horizontal spacer to push your 2nd status bar to the bottom. It doesn't make much sense to call move()on a widget in a layout.

      I am sure you have read everything about status bars, layouts and main windows.

      Software Engineer
      The Qt Company, Oslo

      C 1 Reply Last reply 13 Apr 2024, 16:56
      0
      • A Axel Spoerl
        13 Apr 2024, 14:20

        @AnneRanch
        The only obvious mistake is the last line statusBar()->addWidget(secondstatusbar);
        Since you show only parts of your code, we don't know what thisis. If it inherits from QMainWindow, don't add the second status bar to the main window layout. Add a layout to your central widget, add a horizontal spacer to push your 2nd status bar to the bottom. It doesn't make much sense to call move()on a widget in a layout.

        I am sure you have read everything about status bars, layouts and main windows.

        C Online
        C Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 13 Apr 2024, 16:56 last edited by
        #3

        @Axel-Spoerl How dare you to mention layouts here? It's forbidden: https://forum.qt.io/topic/155559/another-reuse-question !

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        A 1 Reply Last reply 13 Apr 2024, 17:31
        2
        • C Christian Ehrlicher
          13 Apr 2024, 16:56

          @Axel-Spoerl How dare you to mention layouts here? It's forbidden: https://forum.qt.io/topic/155559/another-reuse-question !

          A Offline
          A Offline
          Axel Spoerl
          Moderators
          wrote on 13 Apr 2024, 17:31 last edited by
          #4

          @Christian-Ehrlicher
          Shame on me.

          Software Engineer
          The Qt Company, Oslo

          1 Reply Last reply
          0
          • C Christian Ehrlicher referenced this topic on 14 Apr 2024, 18:37

          3/4

          13 Apr 2024, 16:56

          • Login

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