PDA

View Full Version : Multiple Window Class Variables



2lights
16th July 2013, 12:25
Qt colleagues :)

I have multiple windows(ControlWindow, NewWindow)

How do I pass variables between windows (From ControlWindow to NewWindow & NewWindow to ControlWindow)

ControlWindow CreateNewWindow button creates a newWindow.
ControlWindow also has an upload image Button that loads an image in the label of the new window.
ControlWindow holds the name of image(QString) & the QImage

In my newWindow Constructor


MainWindow TempMain; //probably because im creating a new instance of mainWindow variables are blank!
//But that than how do I call the getter Functions of mainWindow from newWindow?
//Nothing loads, the QString & Qimage is blank?
QString tempName = TempMain.getName();
QImage tempImage = TempMain.getImage();

tempImage .load(tempName);
ui->labelImage->setPixmap(QPixmap::fromImage(tempImage));




Help please. Ideas :)

Signals and slots, Maybe?:confused:

anda_skoa
20th July 2013, 18:46
You can of course always use signal/slot.

Also, if MainWindow holds a pointer to your new window, than it can access all its public methods, so it can call setters and getters.

Cheers,
_