Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Access statisBar from member function
Qt 6.11 is out! See what's new in the release blog

Access statisBar from member function

Scheduled Pinned Locked Moved Unsolved C++ Gurus
4 Posts 2 Posters 761 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.
  • M Offline
    M Offline
    MatFox
    wrote on last edited by
    #1

    Hello QT-world,

    how can I access the statusbar in my mainwindow from any member or nonmember function. I have no clue how do accomplish that. It exceeds my actual knowledge base.
    This is what I have so far:

    QtDemo::QtDemo(QWidget *parent) : QMainWindow(parent)
    {
    QWidget *widget = new QWidget;
    ...
    // set a message into staticBar
    statusBar()->showMessage(any_message);
    ...
    any_function();
    }

    void QtDemo :: any_function()
    {
    QtDemo *n;
    n->statusbar->showMessage(...); // does not work, not that member showMessage() !!
    ...
    }

    Who has the right solution?
    Best wishes
    MatFox

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      @MatFox said in Access statisBar from member function:

      void QtDemo :: any_function()
      {
      QtDemo *n;
      n->statusbar->showMessage(...); // does not work, not that member showMessage() !!
      ...
      }

      Why are you creating n in the first place ?
      Just do the same thing you did in the constructor.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • M Offline
        M Offline
        MatFox
        wrote on last edited by
        #3

        Hi SGaist,

        what do you mean? Could you be more specific?
        Do mean QtDemo* n = new ... ; etc.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Well, why are you creating a local pointer to a QtDemo object within a method that is part of QtDemo ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          • Login

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