[solved] statusbar() was not declared in this scope.



  • Hi,

    I just started QT so forgive noob question.

    I created a MainWindow using QT designer designed to show a message in the status bar when a button is clicked.
    Given below is the slot that I implemented:

    @
    void MainWindow:: on_pushButton_clicked()
    {
    label = new QLabel("X");
    statusbar->addWidget(label);

    }
    @

    However, I get an error saying satusbar() was not declared in this scope.
    Given below is my .h file:

    @
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>
    #include <QStatusBar>
    #include <QLabel>

    namespace Ui {
    class MainWindow;
    }

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    private:
    Ui::MainWindow *ui;
    QLabel *label;

    private slots:
    void on_pushButton_clicked();
    };

    #endif // MAINWINDOW_H
    @

    Kindly help. Thanks.

    [edit: Code highlighted / Denis Kormalev]



  • Found the issue. Typo.
    It's supposed to be statusBar not statusbar.
    Silly me.



  • Hey ritratt, nice to see you found the issue.
    Could you please format the code you posted, using @ characters around it? Thanks =)


Log in to reply
 

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