Results 1 to 6 of 6

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

  1. #1
    Join Date
    Sep 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Angry 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??

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

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

    try this
    Qt Code:
    1. ...
    2. this->statusBar()->showMessage(tr("File successfully loaded."), 3000);
    3. ...
    To copy to clipboard, switch view to plain text mode 
    looks like you have a member in Ui_MainWindow which is named as statusBar.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Sep 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

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

    No, it dowsnt work...
    But this works..

    Qt Code:
    1. QMainWindow::statusBar()->showMessage(tr("File successfully loaded."), 3000);
    To copy to clipboard, switch view to plain text mode 

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

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default 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?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  6. #6
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.