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?
QtWS25 Last Chance

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 483 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 last edited by Anonymous_Banned275
    #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);
               
                       
                       
    
    Axel SpoerlA 1 Reply Last reply
    0
    • A Anonymous_Banned275

      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);
                 
                         
                         
      
      Axel SpoerlA Offline
      Axel SpoerlA Offline
      Axel Spoerl
      Moderators
      wrote on 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

      Christian EhrlicherC 1 Reply Last reply
      0
      • Axel SpoerlA Axel Spoerl

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

        Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 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

        Axel SpoerlA 1 Reply Last reply
        2
        • Christian EhrlicherC Christian Ehrlicher

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

          Axel SpoerlA Offline
          Axel SpoerlA Offline
          Axel Spoerl
          Moderators
          wrote on last edited by
          #4

          @Christian-Ehrlicher
          Shame on me.

          Software Engineer
          The Qt Company, Oslo

          1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher referenced this topic on

          • Login

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