PDA

View Full Version : Passing of Parameters in two classes



StarRocks
16th October 2012, 11:57
Dear Forums,


Hi Guys i have a doubt regarding QT related.....I just want to know how to pass parameters from one page to another.........Lemme explain in clear I have screens as A and B in A i have a field by name Mobilenumber and the next screen i have a field by name as Name,Address etc......Now what i need is when i enter the mobilenumber as 1234567890 and give click on the submit button,it should display the related information of that mobile number in the next page........I know we can use cookies,Sessions etc but will be a vast process can any one give me better solution with an example program.........Any solution would be appreciable..........Thanks in Advance........


Regards,

Santosh Reddy
16th October 2012, 13:17
If you are using QWizard and QWizardPage based widgets you can use registerField() and field() to wirte and read values between pages

StarRocks
16th October 2012, 13:51
Dear Santosh,

Thanks for the reply.....I used QMainwindow if im not wrong it would be greatful if you mail and show me in the form of an Example..Coz it might help others too a lot who are in need of.......I just need to pass the parameters thats all thats the problem im facing now.....Thanks in Advance........Any Solution would be appreciable....


Regards,

ChrisW67
17th October 2012, 01:46
Here is what I take from your question:

You have two classes representing two forms.
You have a private member variable representing the phone number edit box in form A.
Form B needs the text from the private member variable in Form A.
All the talk of sessions and cookies has nothing to do with a desktop application: these are web application concepts.


Do you know any C++? Here are two pure C++ approaches:

You can expose the private value using a public getter function in Form A so that Form B can get the value.
You can expose a public setter function in Form B so that Form A can push the value into Form B


Here is a Qt flavoured approach: Have Form A emit a signal when the value is changed and connect that to a slot in Form B.

What you do depends on what your application requirements are and how the user interaction is supposed to flow.

sonulohani
17th October 2012, 06:48
Check this example:- 8312

Maybe this will help.