参考Qt学习笔记(七):状态栏
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent):QMainWindow(parent){
this->resize(1200,1300);
QStatusBar *qstBar = this->statusBar();
QLabel *qllabel = new QLabel("左侧状态栏信息",this);
QLabel *qllabel2 = new QLabel("左侧状态栏信息2",this);
qstBar->addWidget(qllabel);
qstBar->addWidget(qllabel2);
QLabel *qrlabel = new QLabel("右侧状态栏信息",this);
qstBar->addPermanentWidget(qrlabel);
}
MainWindow::~MainWindow()
{
delete ui;
}
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QPushButton>
#include <QDebug>
#include <QMenuBar>
#include <QMenu>
#include <QAction>
#include <QToolBar>
#include <QLabel>
#include <QStatusBar>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void setSeparat(QMenu *ptr=0);
private:
Ui::MainWindow *ui;
};
#endif
效果演示