[Qt-interest] adressing something to the mainWindow from a dialog
Malyushytsky, Alex
alex at wai.com
Tue Apr 7 01:05:28 CEST 2009
Please take into the count that correctly asked question is at least half of a right answer. And I afraid I might not understand it right.
So asssume you have vaiable 'var' in your MainWindow class.
class MainWindow
{
...........
int var;
...........
}
Remember that variable 'var' makes sence only withing MainWindow object.
Even you have only one object, you should have allocate it somewhere, probably like this:
MainWindow* mainWindow = new ........;
So first thing you need is a pointer to your mainWindow object.
How you get it, depends on the code, here I would assume that you can access it, by storing the pointer in a global variable. (I don't recommend this way, it is just chosen for simplicity).
Once you have an access to a pointer to MainWindow object in your module (a dialog window):
- if var variable is public, you can get and set it directly, like mainWindow->var = 3; int mainWindow->var = 4;
- if it is protected or private, you can either add public methods (functions) to MainWindow which will return or set value of val, etc.
Now I hope this helps.
But I would ask you to remember that QT interest forum is not a place for basic C++ questions.
The reason is that most of people read and post here in their free time.
And they don't like to dig through non-qt related questions all the time, because they were currently interested in specific product, even they were willing to help you.
There are special forums for C++ beginners. Try to find one. You might find much more help there too.
Best regards,
Alex
________________________________________
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Giancarlo Amati
Sent: Monday, April 06, 2009 9:17 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] adressing something to the mainWindow from a dialog
Hello everybody,
i have this problem, I have a dialog windows from where I want to adress a variable which beloges to may MainWindow class linked to the main application. Is there a way to do it?
Kind regards.
Giancarlo
________________________________________
Scegli fra più di 30 stazioni! Ascolta la radio su Messenger
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
"Please consider our environment before printing this email."
More information about the Qt-interest-old
mailing list