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. [Solved]Getting error "statusBar was not declared in this scope"?!
Forum Updated to NodeBB v4.3 + New Features

[Solved]Getting error "statusBar was not declared in this scope"?!

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 5.0k 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.
  • A Offline
    A Offline
    ankursaxena
    wrote on last edited by
    #3

    Since You haven't told what is statusBar exactly. I am assuming that you are using statusBar() function.

    then please check that have you declared statusBar() method in header file correctly or not.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      reem9611
      wrote on last edited by
      #4

      I am tryieng to implement what I need from this example

      @#include <QGridLayout>
      #include <QLabel>
      #include <QFrame>
      #include <QStatusBar>
      #include "statusbar.h"

      Statusbar::Statusbar(QWidget *parent)
      : QMainWindow(parent)
      {
      QFrame *frame = new QFrame(this);
      setCentralWidget(frame);

      ok = new QPushButton("OK", frame);
      ok->move(20, 50);

      apply = new QPushButton("Apply", frame);
      apply->move(120, 50);

      statusBar();

      connect(ok, SIGNAL(clicked()), this, SLOT(OnOkPressed()));
      connect(apply, SIGNAL(clicked()), this, SLOT(OnApplyPressed()));
      }

      void Statusbar::OnOkPressed()
      {
      statusBar()->showMessage("OK button pressed", 2000);
      }

      void Statusbar::OnApplyPressed()
      {
      statusBar()->showMessage("Apply button pressed", 2000);
      }@
      [quote author="SGaist" date="1405505571"]Hi,

      And when I compile the code I get this error

      Can you show the code that is failing ?[/quote]

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

        The name of your widget is not really a good idea, MainWindow would be more meaningful and less error prone.

        Do you have by any chance a member variable that's name statusBar ?

        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
        0
        • A Offline
          A Offline
          ankursaxena
          wrote on last edited by
          #6

          In the constructor , you are calling statusBar() method. But it is not defined in the class. I think that's why it is showing this error.

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

            ankursaxena It is: "QMainWindow::statusBar()":http://qt-project.org/doc/qt-5/qmainwindow.html#statusBar

            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
            0
            • A Offline
              A Offline
              ankursaxena
              wrote on last edited by
              #8

              Ohk Gaist sir. Now i got it.

              I have run this code. and It is working perfectly.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                reem9611
                wrote on last edited by
                #9

                Yes the code is work when I create a project with base class QMainWindow ,

                however when I implement that on my project which the base class is QDialog the error is appear ..

                [quote author="SGaist" date="1405510932"]ankursaxena It is: "QMainWindow::statusBar()":http://qt-project.org/doc/qt-5/qmainwindow.html#statusBar[/quote]

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  ankursaxena
                  wrote on last edited by
                  #10

                  Because statusBar() is defined in the QMainWindow class and I searched and found that it is not defined in QDialog.

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    reem9611
                    wrote on last edited by
                    #11

                    thanks all for your replies ..
                    I find a solution Yes as you said statusBar() is defined in QMainWindow class and it is not define in QDialog class.

                    what I did is adding status bar manually using a layout

                    @ QLayout *l = new QVBoxLayout(ui->frame);

                             QStatusBar *bar = new QStatusBar;
                             l->addWidget(bar);
                    

                    @
                    [quote author="ankursaxena" date="1405575930"]Because statusBar() is defined in the QMainWindow class and I searched and found that it is not defined in QDialog.[/quote]

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

                      That's the kind of "minor" detail that you should mention from start

                      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
                      0

                      • Login

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