Unsolved giving value to int in other class from mainwindow.cpp
-
Hello. there.. I want to change variable value from mainwindow.cpp (mainwindow.h) to scene.h..
So that i can do some logic in scene.cpp... by checking variable value;
variable is int test;I have mainwindow.h which look like this
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "scene.h"namespace Ui {
class MainWindow;
}class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
explicit MainWindow(QWidget *parent = 0);
QList<QString> clickedData;
~MainWindow();private slots:
void on_pushButtonChange_clicked();private:
Ui::MainWindow *ui;
QGraphicsView *view; //just pointers
QGraphicsItem *item;
QGraphicsScene scene;
QAction selectAction;
};#endif // MAINWINDOW_H
Now so if I click on on_pushButtonChange then it should give variable a value in other class called Sceneso scene.h is like this
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsView>class Scene : public QGraphicsScene //inherit
{
public:
Scene(QObject* parent = 0); //construct.
int test; //this should be changed so that I can do some logics
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event;
};#endif // SCENE_H
Thanks for help.
-
Hi,
Where do you have an instance of Scene ?