Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMainWindow::statusBar() no object
Forum Updated to NodeBB v4.3 + New Features

QMainWindow::statusBar() no object

Scheduled Pinned Locked Moved General and Desktop
5 Posts 5 Posters 6.3k Views 1 Watching
  • 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 Offline
    E Offline
    erik kruyt
    wrote on last edited by
    #1

    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
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      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
      0
      • F Offline
        F Offline
        Frank
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • N Offline
          N Offline
          ngrosjean
          wrote on last edited by
          #4

          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
          0
          • D Offline
            D Offline
            DenisKormalev
            wrote on last edited by
            #5

            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
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved