Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    QMainWindow::statusBar() no object

    General and Desktop
    5
    5
    5865
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      erik kruyt last edited by

      According to the Qt documentation you can call
      QMainWidnow::statusBar()->showMessage
      from anywhere in the application.
      However, I get an error: no object, so I have to pass the QMainWindow object as an argument wherever I want to apply the statusbar.
      What is wrong?

      1 Reply Last reply Reply Quote 0
      • F
        Franzk last edited by

        There is nothing wrong. QMainWindow::statusBar() is just not a static function. Besides, most widgets provide status tips. Have a look at the QWidget source to get an idea on how status tips are handled.

        "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply Reply Quote 0
        • F
          Frank last edited by

          You can have multiple mainwindows (and statusbars), so a static statusBar() wouldn't work.

          1 Reply Last reply Reply Quote 0
          • N
            ngrosjean last edited by

            The syntax : QMainWidnow::statusBar()->showMessage is only available for static method, and QMainWidnow::statusBar() is not a static method.
            You don't really need to pass the QMainWindow object as an argument, :
            -> just pass a reference / pointer to the QStatusBar,
            or
            -> use the signal / slot mechanism as QStatusBar::showMessage is a slot...

            1 Reply Last reply Reply Quote 0
            • D
              DenisKormalev last edited by

              I think that using signal/slot mechanism will be good here. Something like slot that actually does the statusbar stuff in your mainWindow and connections with all objects from which you need to change statusbar.
              Also if you have only one mainwindow you can make it singleton and happily use statusBar(). For example, you have MyMainWindow class inherited from QMainWindow and have getInstance() in it, returning actual instance of your main window. So you can just use @MyMainWindow::getInstance()->statusBar()->showMessage()@

              1 Reply Last reply Reply Quote 0
              • First post
                Last post