Reputation: 5175
I have 2 dialogs. Dialog A accepts some data from the user and stores it in a variable. Now I want to use this variable in a Dialog B. What is a simple way to do this? Dialog B is instantiated from dialog A itself.
Upvotes: 0
Views: 544
Reputation: 1788
You can use extern variable.
In your dialog A declare global variable (outside of any method/function), for example int Number. Now in your dialog B declare extern variable, for example: extern int Number. Now whatever data you store in Number it will be available in your extern variable.
Upvotes: 1
Reputation: 38112
The strongest feature in Qt is signal slot system.
So do it with signal and slots. When you creating a dialog give him a slot which shows this dialog and accepts values required for this dialog. Dialog should also fire a signal when edited value changes or when this value is approved.
This approach makes each part of code very independent from each other, make it scalable and easer to maintain.
Upvotes: 2