PDA

View Full Version : Using a form handle in another form



vishal.chauhan
15th January 2007, 13:41
Hi All,

I am using Qt 4.2.2 on my Intel Mac.
I have a MainWindow named MainForm which have a Widget ProgressBar.

Now I m doing the following things.

1. When I click on a toolbar icon in my MainForm and opening a Dialog(HeaderDlg).

2. Then I click the ok button of the open Header dialog which is then accepted on Ok click.

3. Then on that dialog accept I m creating a class Recovery object (Recovery r) in my MainForm class.

4. and then calling some function of Recovery class with that objec in the MainForm class.

5.Then it is doing some working in the recovery class now I want to show the value of a variable counter in the ProgressBar of MainForm class.

I m declaring the Form Pointer and using it as--

extern void *MainFormPtr;
MainForm *mainform1=(MainForm*)MainFormPtr;
mainform->progressBar->setValue(counter);

Now it is not working but when I debug the program the mainform pointer value is 0X00.
But If I declare the object as

MainForm *mainform=new MainForm(0);

Then it is giving pointer value but ot showing the increase value of Progress bar .


If anybody knows what I m doing wrong then plz tell me.

Thanks.

wysota
15th January 2007, 14:52
I think you should use signals and slots instead of such complex constructions. Especially get rid of that global pointer.