PDA

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



shadyabhi
30th December 2009, 15:41
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??

spirit
30th December 2009, 16:14
try this


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

looks like you have a member in Ui_MainWindow which is named as statusBar.

shadyabhi
30th December 2009, 16:56
No, it dowsnt work...
But this works..


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

BUT, MAIN AGENDA IS, IS IT A BUG??

spirit
30th December 2009, 16:59
I don't think so.
can you attach compilable example which reproduces the problem?

faldzip
30th December 2009, 21:03
How are you using Ui_MainWindow class? can you show us more code? At least your mainwindow.h

squidge
30th December 2009, 23:40
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.