Split QStatusBar and choose where to display QStatusTips

  • I'm wondering how to split the QStatusBar in my QMainWindow into two equal parts and to subsequently show QStatusTips in either the left or the right part.

    Perhaps this approach is a step in the right direction —

    1.) Create two QLabels*,

    labelStatusTip = new QLabel("");
    labelGeneralInfo = new QLabel("Initial text");

    2.) Add them to the QStatusBar, setting stretch to 1 results in two equal parts (same widths)

    ui->statusBar->addPermanentWidget(labelStatusTip, 1);
    ui->statusBar->addPermanentWidget(labelGeneralInfo, 1);

    3.) Now, how do I set the text of labelStatusTip to the actual QStatusTips? Do I have to define a custom QStatusBar and override the showMessage() and clearMessage() slots (see http://doc.qt.io/qt-5/qstatusbar.html)?

  • Hmm, this works —

    connect(ui->statusBar, SIGNAL(messageChanged(QString)), this, SLOT(showStatusTip()));
    void MyMainWindow::showStatusTip() {

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.