Andre008
19th February 2016, 18:52
Hello,
i have create a dialog project with the Qt Creator which contains a code is as follows:
dialog.h:
class Dialog;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
private:
Ui::Dialog *ui;
QGraphicsScene *scene;
MemberClass mClass;
};
dialog.cpp
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
scene = new QGraphicsScene(this);
ui->graphicsView->setScene(scene);
}
From this point it is possible to add items with " scene->addItem(...)" to the scene.
How it is possible to add items to the scene from outside of the dialog class?
For Example:
memberClass.h
class MemberClass
{
public:
void addtoScene();
};
memberClass.cpp
void MemberClass::addtoScene()
{
//Here an item should be add to the scene of the dialog class
}
Thx,
Andre
i have create a dialog project with the Qt Creator which contains a code is as follows:
dialog.h:
class Dialog;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
private:
Ui::Dialog *ui;
QGraphicsScene *scene;
MemberClass mClass;
};
dialog.cpp
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
scene = new QGraphicsScene(this);
ui->graphicsView->setScene(scene);
}
From this point it is possible to add items with " scene->addItem(...)" to the scene.
How it is possible to add items to the scene from outside of the dialog class?
For Example:
memberClass.h
class MemberClass
{
public:
void addtoScene();
};
memberClass.cpp
void MemberClass::addtoScene()
{
//Here an item should be add to the scene of the dialog class
}
Thx,
Andre