I have following code snippet. I want to access my stack from another class. (This stack is filled with QWidgets which i need in some other classes). But i didn't even get as far as initializing my static variable in my mainwindow constructor. The error message is : "qualified-id in declaration before '=' token"
/*mainwindow.h*/
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0); //Konstruktor
~MainWindow(); //Destruktor
//static QStack<QWidget*> *widgetStack;
//static QStack<QWidget*> getWidgetStack();
static QStack<QWidget*> *widgetStack;
private:
Ui::MainWindow *ui;
/*mainwindow.cpp*/
MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainWindow)
{
/*ui->setupUi(this);
QStack<QWidget*> *MainWindow::widgetStack = new QStack<QWidget*>();
}
/*A method in another class*/
void Support::on_Taster_Power_clicked()
{
MainWindow.widgetStack->pop();
}
I tried really a lot but nothing worked out for me. please help. thanks in advance
/*mainwindow.cpp*/
QStack<QWidget*> *MainWindow::widgetStack = new QStack<QWidget*>();
MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainWindow)
{
/*ui->setupUi(this); */
}