Congratulations to our 2022 Qt Champions!

Unable to set the the text in statusbar

  • I am trying to display text in the status bar on hover of QAction using below code.
    Debug log is outputted but the text has not been set.
    Please suggested how to set the text in status bar area on QActionHover.

    This is connect function:-
    connect(ui->PoewControl_actionNew, &QAction::hovered, this, &MainWindow::showMessage);

    void MainWindow::showMessage()

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Is MainWindow a QMainWindow ? If so, then you should only call statusBar()->showMessage("My message");. QMainWindow already has a status bar. will create the status bar the first time you call statusBar() unless you called setStatusBar with a custom one.

  • I have used "statusBar()->showMessage("some string ")" instead of "ui->statusbar->showMessage("showMessage")"
    but still, the text is not displayed in statusbar.

  • Moderators

    @Durgesh said in Unable to set the the text in statusbar:

    Debug log is outputted

    Good, this shows that your slot is getting called successfully

    but the text has not been set.

    I suggest you connect the signal, QStatusBar::messageChanged(QString) to a slot for debugging -- print every message to qDebug().

    After you make the connection, call showMessage() directly to make sure the QStatusBar is being displayed correctly.

    Finally, the documentation might contain some clues:

Log in to reply