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.
Is this a bug in QT4??
Re: Why is this error: reference to ‘statusBar’ is ambiguous.. coming? Is this a bug?
try this
Code:
...
this->statusBar()->showMessage(tr("File successfully loaded."), 3000);
...
looks like you have a member in Ui_MainWindow which is named as statusBar.
Re: Why is this error: reference to ‘statusBar’ is ambiguous.. coming? Is this a bug?
No, it dowsnt work...
But this works..
Code:
QMainWindow::statusBar()->showMessage
(tr
("File successfully loaded."),
3000);
BUT, MAIN AGENDA IS, IS IT A BUG??
Re: Why is this error: reference to ‘statusBar’ is ambiguous.. coming? Is this a bug?
I don't think so.
can you attach compilable example which reproduces the problem?
Re: Why is this error: reference to ‘statusBar’ is ambiguous.. coming? Is this a bug?
How are you using Ui_MainWindow class? can you show us more code? At least your mainwindow.h
Re: Why is this error: reference to ‘statusBar’ is ambiguous.. coming? Is this a bug?
One statusBar should be part of ui object, and another part of QMainWindow, so you shouldn't have a problem. However, if you use multiple inheritance you will likely get the problem you describe as then ui elements become part of your class and you then have two statusBar's in the same scope.
That would also explain why QMainWindow::statusBar works.