I can think of two possible ways, the first way you show your dialog, then after it closed with Ok status you can call dedicated dialog method to get your configured device.
class DialogV2 {
public:
YourObject *getConfiguredObject () {
return new YourObject;
};
};
class DialogV2 {
public:
YourObject *getConfiguredObject () {
return new YourObject;
};
};
To copy to clipboard, switch view to plain text mode
A slightly alternative approach would be to return configuration structure with all necessary parameters and then create the device in your main window class (like QFileOpenDialog returning file name and then you create a QFile out of it).
Another way is to using signals and slots
class MainWindow {
public slots:
void objectCreated(YourObject *o);
};
class Dialog {
private slots:
void onCreateClicked () {
YourObject *obj = new YourObject;
emit objectCreated (obj);
};
signals:
void objectCreated (YourObject *o);
};
class MainWindow {
public slots:
void objectCreated(YourObject *o);
};
class Dialog {
private slots:
void onCreateClicked () {
YourObject *obj = new YourObject;
emit objectCreated (obj);
};
signals:
void objectCreated (YourObject *o);
};
To copy to clipboard, switch view to plain text mode
But it has two downsides that iI can think of:
1. You need to trace the lifetime of your object, and don't get it lost when signal is unconnected.
2. Object creation and corresponding slot will be called while dialog is still active, which can be undesirable behaviour.
Generally I suggest first solution, second solution is better if you generate lightweight value-type objects and don't really care about them.
Bookmarks