[Solved]Getting error "statusBar was not declared in this scope"?!
I would like to use statusBar() in my application to show some information ,I tried first to implement some examples to understand the concept of the statusBar ,however I don't know why I get this error "statusBar was not declared in this scope"?!
Can you show the code that is failing ?
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.
I am tryieng to implement what I need from this example
QFrame *frame = new QFrame(this);
ok = new QPushButton("OK", frame);
apply = new QPushButton("Apply", frame);
connect(ok, SIGNAL(clicked()), this, SLOT(OnOkPressed()));
connect(apply, SIGNAL(clicked()), this, SLOT(OnApplyPressed()));
statusBar()->showMessage("OK button pressed", 2000);
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]
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 ?
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.
ankursaxena It is: "QMainWindow::statusBar()":http://qt-project.org/doc/qt-5/qmainwindow.html#statusBar
Ohk Gaist sir. Now i got it.
I have run this code. and It is working perfectly.
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]
Because statusBar() is defined in the QMainWindow class and I searched and found that it is not defined in QDialog.
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]
That's the kind of "minor" detail that you should mention from start