Search code examples
c++qt4ambiguous

Why is this error: reference to ‘statusBar’ is ambiguous.. coming? Is this a bug?


I created a QMainWindow using QT Designer. As we know, it has statusBar by default.

By default, QT Designer gave its objectname as "statusBar". Now, when I tried to call like:-

statusBar()->showMessage(tr("File successfully loaded."), 3000);

as we have a function with prototype: QStatusBar * QMainWindow::statusBar () const

The Compiler shows the error:-

error: reference to ‘statusBar’ is ambiguous.

error: candidates are: QStatusBar* Ui_MainWindow::statusBar

error: QStatusBar*QMainWindow::statusBar() const

Actually, i was following a book "The Art of Building Qt Applications by DANIEL MOLKENTIN". And I am compiling the same code given in book.

Above code is in mainwindows.cpp and i have included "mainwindow.h" & "ui_mainwindow.h" in it...

Is this a bug in QT4??


Solution

  • Ask for a specific version of the method statusBar():

    Ui_MainWindow::statusBar()->showMessage(tr("File successfully loaded."), 3000);