I don't see any call to main_window->show() in your main(). That should happen just before app.exec().
Edit: Your code is extremely confused. I see now that you call show() in createWidgets(), but this method is commented out.
And this code:
this->camera_1 = &QImage(img);
this->camera_2 = &QImage(img);
this->camera_1 = &QImage(img);
this->camera_2 = &QImage(img);
To copy to clipboard, switch view to plain text mode
is totally wrong. You are creating two QImage instances -on the stack (QImage(img))- and these instance are destroyed immediately when your method exits. So camera_1 and camera_2 are assigned pointer values which become invalid and dangling as soon as the method is done.
To do this correctly, you could change camera_1 and camera_2 from being QImage * to simply QImage and just assign the incoming image to them:
// .h:
// .cpp:
this->camera_1 = img;
this->camera_2 = img;
// .h:
QImage camera_1;
QImage camera_2;
// .cpp:
this->camera_1 = img;
this->camera_2 = img;
To copy to clipboard, switch view to plain text mode
The same error occurs here:
this->cam1 = &tmp_label;
this->cam2 = &tmp_label;
this->cam1 = &tmp_label;
this->cam2 = &tmp_label;
To copy to clipboard, switch view to plain text mode
You are assigning the address of a temporary QLabel variable which gets destroyed as soon as the method exits, so cam1 and cam2 end up pointing to a non-existent QLabel instance.
You need to go back to your C++ textbook and read about variables and scoping.
Bookmarks