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. Additional QStatusbar
Qt 6.11 is out! See what's new in the release blog

Additional QStatusbar

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 2.0k 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.
  • U Offline
    U Offline
    UFSBoyden
    wrote on last edited by
    #1

    Hi

    I want to add an QStatusbar above a current QStatusbar in a QMainWindow. I am developing a hardware interface, which has a lot of status updates, but I don't want to clutter main window with bunch on updating labels.

    Using previous recommendations I added a layout (QVBoxLayout) named statusbar and added the additional QStatusbar to this.

    ui code snippet:

    <widget class="QWidget" name="verticalLayoutWidget">
        <property name="geometry">
         <rect>
          <x>-1</x>
          <y>251</y>
          <width>831</width>
          <height>21</height>
         </rect>
        </property>
        <layout class="QVBoxLayout" name="statusbar"/>
       </widget>
      </widget>
    

    cpp code snippet:

    //Add second statusbar
        statusCameraBar = new QStatusBar(this);
        ui_Spica->statusbar->addWidget(statusCameraBar); 
    

    I could then add updating labels using addPermanentWidget to it. It displays well.

    BUT: It is locked in place and does not resize with the MainWindow.

    How can I lock it to the current QStatusBar of the MainWindow so that it moves and resizes with it, or is there a way to add an additional Row of widgets to the current QStatusbar.

    I want to display 8 status labels in total spread over two levels.

    Please help
    Pat

    jsulmJ 1 Reply Last reply
    0
    • U UFSBoyden

      Hi

      I want to add an QStatusbar above a current QStatusbar in a QMainWindow. I am developing a hardware interface, which has a lot of status updates, but I don't want to clutter main window with bunch on updating labels.

      Using previous recommendations I added a layout (QVBoxLayout) named statusbar and added the additional QStatusbar to this.

      ui code snippet:

      <widget class="QWidget" name="verticalLayoutWidget">
          <property name="geometry">
           <rect>
            <x>-1</x>
            <y>251</y>
            <width>831</width>
            <height>21</height>
           </rect>
          </property>
          <layout class="QVBoxLayout" name="statusbar"/>
         </widget>
        </widget>
      

      cpp code snippet:

      //Add second statusbar
          statusCameraBar = new QStatusBar(this);
          ui_Spica->statusbar->addWidget(statusCameraBar); 
      

      I could then add updating labels using addPermanentWidget to it. It displays well.

      BUT: It is locked in place and does not resize with the MainWindow.

      How can I lock it to the current QStatusBar of the MainWindow so that it moves and resizes with it, or is there a way to add an additional Row of widgets to the current QStatusbar.

      I want to display 8 status labels in total spread over two levels.

      Please help
      Pat

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @UFSBoyden Is ui_Spica->statusbar itself in a layout?

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

      1 Reply Last reply
      0
      • U Offline
        U Offline
        UFSBoyden
        wrote on last edited by UFSBoyden
        #3

        It is the layout. I is inside the MainWindow layout. See below the whole ui code...

        <?xml version="1.0" encoding="UTF-8"?>
        <ui version="4.0">
         <class>MainWindow</class>
         <widget class="QMainWindow" name="MainWindow">
          <property name="geometry">
           <rect>
            <x>0</x>
            <y>0</y>
            <width>828</width>
            <height>337</height>
           </rect>
          </property>
          <property name="windowTitle">
           <string>MainWindow</string>
          </property>
          <property name="styleSheet">
           <string notr="true">background: url(:/stars.png);</string>
          </property>
          <widget class="QWidget" name="centralWidget">
           <property name="enabled">
            <bool>true</bool>
           </property>
           <property name="autoFillBackground">
            <bool>false</bool>
           </property>
           <widget class="QWidget" name="verticalLayoutWidget">
            <property name="geometry">
             <rect>
              <x>-1</x>
              <y>251</y>
              <width>831</width>
              <height>21</height>
             </rect>
            </property>
            <layout class="QVBoxLayout" name="statusbar"/>
           </widget>
          </widget>
          <widget class="QMenuBar" name="menuBar">
           <property name="geometry">
            <rect>
             <x>0</x>
             <y>0</y>
             <width>828</width>
             <height>26</height>
            </rect>
           </property>
          </widget>
          <widget class="QToolBar" name="mainToolBar">
           <property name="enabled">
            <bool>true</bool>
           </property>
           <attribute name="toolBarArea">
            <enum>TopToolBarArea</enum>
           </attribute>
           <attribute name="toolBarBreak">
            <bool>false</bool>
           </attribute>
          </widget>
          <widget class="QStatusBar" name="statusInfoBar">
           <property name="autoFillBackground">
            <bool>true</bool>
           </property>
          </widget>
         </widget>
         <layoutdefault spacing="6" margin="11"/>
         <resources/>
         <connections/>
        </ui>
        
        

        And in addition the constructor cpp code...

        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui_Spica(new Ui::MainWindow)
        {
            ui_Spica->setupUi(this);
        
            //Set init variables to NULL
            winAbout = NULL;
            winInfo = NULL;
        
            //Set app environment and values, names, icons and etc.
            setWindowTitle("Spica");
            setWindowIcon(QIcon(":/resources/boyden.ico"));
        
            QPixmap bkgnd(":/resources/stars.xpm");
            QPalette palette;
            palette.setBrush(QPalette::Background, bkgnd);
            this->setPalette(palette);
        
            //Add second statusbar
            statusCameraBar = new QStatusBar(this);
            ui_Spica->statusbar->addWidget(statusCameraBar);
            statusCameraBar->setAutoFillBackground(true);
        
            //Add labels to camera status bar
            camconnect = new QLabel("Camera Offline", this);
            camconnect->setFrameStyle(QFrame::Panel | QFrame::Sunken);
            camstatus = new QLabel("Camera Status", this);
            camstatus->setFrameStyle(QFrame::Panel | QFrame::Sunken);
            camtemp = new QLabel("Camera Temp", this);
            camtemp->setFrameStyle(QFrame::Panel | QFrame::Sunken);
            camdrive = new QLabel("Camera Drive", this);
            camdrive->setFrameStyle(QFrame::Panel | QFrame::Sunken);
            statusCameraBar->addPermanentWidget(camconnect, 1);
            statusCameraBar->addPermanentWidget(camstatus, 1);
            statusCameraBar->addPermanentWidget(camtemp, 1);
            statusCameraBar->addPermanentWidget(camdrive, 1);
        
            //Add labels to info status bar
            telconnect = new QLabel("Telescope Offline", this);
            telconnect->setFrameStyle(QFrame::Panel | QFrame::Sunken);
            fwconnect = new QLabel("Filter Wheel Offline", this);
            fwconnect->setFrameStyle(QFrame::Panel | QFrame::Sunken);
            lst = new QLabel("LST", this);
            lst->setFrameStyle(QFrame::Panel | QFrame::Sunken);
            mjd = new QLabel("MJD", this);
            mjd->setFrameStyle(QFrame::Panel | QFrame::Sunken);
        
            ui_Spica->statusInfoBar->addPermanentWidget(telconnect, 1);
            ui_Spica->statusInfoBar->addPermanentWidget(fwconnect, 1);
            ui_Spica->statusInfoBar->addPermanentWidget(lst, 1);
            ui_Spica->statusInfoBar->addPermanentWidget(mjd, 1);
        
        }
        
        1 Reply Last reply
        0

        • Login

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