Hello,
i have create a dialog project with the Qt Creator which contains a code is as follows:
dialog.h:
class Dialog;
}
{
Q_OBJECT
public:
explicit Dialog
(QWidget *parent
= 0);
~Dialog();
private:
Ui::Dialog *ui;
MemberClass mClass;
};
class Dialog;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
private:
Ui::Dialog *ui;
QGraphicsScene *scene;
MemberClass mClass;
};
To copy to clipboard, switch view to plain text mode
dialog.cpp
ui(new Ui::Dialog)
{
ui->setupUi(this);
ui->graphicsView->setScene(scene);
}
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
scene = new QGraphicsScene(this);
ui->graphicsView->setScene(scene);
}
To copy to clipboard, switch view to plain text mode
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();
};
class MemberClass
{
public:
void addtoScene();
};
To copy to clipboard, switch view to plain text mode
memberClass.cpp
void MemberClass::addtoScene()
{
//Here an item should be add to the scene of the dialog class
}
void MemberClass::addtoScene()
{
//Here an item should be add to the scene of the dialog class
}
To copy to clipboard, switch view to plain text mode
Thx,
Andre
Bookmarks