PDA

View Full Version : How to pass values in 1 form to another



maveric
4th June 2008, 10:22
Hi all..

I am developing an application which require passing of values from one form (dialog) to another form (Dialog)..
i had tried many ways but could not attain in getting so...

Actually what i need is....
I have taken an qwt plot widget in the if i right click on plot i get a context menu...
when i choose Change Scale option i get another small dialog asking for entering a value in the line edit..
now what i need is when i enter a particular value in the small dialog it should come back to the main dialog and change the x-axis scale ...
i Have tried enough methods... but failed..
well i am not even getting a particular value to the main dialog...

so any one please help me how to do this...

Thanks in advance....

marcel
4th June 2008, 12:10
http://www.qtcentre.org/forum/f-qt-programming-2/t-how-can-i-access-public-variable-parent-form-13889.html

you need to do it the other way around.

maveric
4th June 2008, 13:32
Hi marcel,

I implemented in this way....
but in return i did'nt get any positive result....
still having the same problem...

can u help me out with this problem...

thanks in advance...





int str43;
if (lineEdit1->text()==NULL)
{
QMessageBox::critical(this,"","Please Input Value in the text Box Provided..");
}
else
{
QMessageBox::information(this,"","Value Changed Successfully...");
str63= lineEdit1->text().toInt();
((ctxtmenu*)parent())->str43 = str63;
this->close();

}
ctxtmenu dialog1(this);
lineEdit1->text()= dialog1.lineEdit23->text().toInt();




Here str43 is the public int variable which is present in the "ctextmenu.h" file...
and at the same time str63 is also an int variable which is present in the local loop which i mentioned above...

marcel
4th June 2008, 15:28
void ctxtmenu::ChangeScale()
{
ScaleChange dialog(this);
dialog.show();
dialog.exec();
//apply new scale here (str43).
}

although you'd be better off with one of the other methods I mentioned in the other thread.
You could also create a signal in the dialog which gets emmitted when you press ok, and connect it to a slot in the main form (pass the new scale value as a signal parameter).

maveric
5th June 2008, 07:18
Hi, Marcel ,

Thanks for responding me...
well i didnt get u can u provide one example so that i can get a clear picture..

please....

Thanks in advance...