In my project i have this 4 classes in separated .h and .cpp file:
Qt Code:
  1. MainWindow::MainWindow(QWidget *parent): QWidget (parent){
  2. built_sphere_window = new BuiltSphere;
  3. built_cylinder_window = new BuiltCylinder;
  4. glWidgetWindow = new GlWidget;
  5. ....}
  7. BuiltCylinder::BuiltCylinder(QWidget *parent) : QWidget(parent){
  8. glWidgetCylinder = new GlWidget;
  9. ....}
  11. BuiltSphere::BuiltSphere(QWidget *parent) : QWidget(parent)
  12. {
  13. glWidgetSphere = new GlWidget;
  14. ....}
  16. GlWidget::GlWidget(QWidget *parent) : QGLWidget(QGLFormat(/* Additional format options */), parent){
  17. alpha = 0; //previous =>25
  18. beta = 0; //previous =>-25
  19. distance = 6; //previous =>2.5
  20. initializeWindow();
  21. ....}
To copy to clipboard, switch view to plain text mode 
from the "mainwindow" i do this calls:
Qt Code:
  1. void MainWindow::built_sphere(){
  2. built_sphere_window->setWindowTitle("Built Sphere");
  3. built_sphere_window->setWindowModality(Qt::ApplicationModal);
  4. built_sphere_window->num_sphere = num_element_inserted->at(1)+1;
  5. built_sphere_window->show();
  6. }
  7. void MainWindow::built_cylinder(){
  8. built_cylinder_window->setWindowTitle("Built Cylinder");
  9. built_cylinder_window->setWindowModality(Qt::ApplicationModal);
  10. built_cylinder_window->num_cyl = num_element_inserted->at(0)+1;
  11. built_cylinder_window->show();
  12. }
To copy to clipboard, switch view to plain text mode 
I have several object to build but at this time just the previous 2.
when i open one of this window i to read the data from the respective var & i'm right to visualize the number of the new object that i want to build.
My question is:
how i can set correctly the signal to send to mainwindow the number that i want only at push to ok button in the build window?
in mainwindow.cpp i think i have to set (i write the call for one build element):
Qt Code:
  1. connect (built_sphere_window, SIGNAL (sig_update_num(const int)), this, SLOT (update_value(const float)));
To copy to clipboard, switch view to plain text mode 
and in the respective slot update the num_element_inserted.
in builtsphere.h:
Qt Code:
  1. signals:
  2. void sig_update_num(const int);
To copy to clipboard, switch view to plain text mode 
in builtsphere.cpp:
Qt Code:
  1. emit sig_update_num(num_sphere+1)
To copy to clipboard, switch view to plain text mode 
I think that the code write like this work, my finally question is:
if i want to read/write a value that is stored in a variable in the main window or in all of other classes from one of it is better do a "QSharedMemory+signal in a class like shareddata.h" to do the job or with the code that i write above?
At this time i do my application in one thread (i want to test it first that run correctly & do the job that i want), next step is do multithread to optimize the performance in multicore processor; so i think that in multithread is better to build a class shareddata.h where i can use the lock() & unlock() functions, is the right way to do the job?