Problem with QDialog class
Hi ,I am using Qt 4.4.0 .In my application I want to access the members/variables of one dialog class in another dialog class.Now I am able to access the variables/members of Mainwindow class in any other dialog.The code i used to access is shown below
Code:
MainWindow *omans = qobject_cast<MainWindow *>(parentWidget());
omans->natimer->stop();
I wrote the above code in other dialog class to access the "natimer " which i was declared in mainwindow.
Now I want to access the member of one dialog class in another dialog class.
I tried the same code to access the member of one dialog class in another dialog class,but the execution get breaks .
So help me to solve the problem.
With Regards,
Sudheer.
Re: Problem with QDialog class
You have to cast the window to the type of your class (not just to a QMainWindow).
A QMainWindow does not exhibit that timer.
(You might also prefer not to access internals of your class like that. How about adding a slot "stopTimer()" to your class?)
HTH
Re: Problem with QDialog class
@Caduel, his class is MainWindow, not QMainWindow.
@Sudheer
Quote:
I tried the same code to access the member of one dialog class in another dialog class,but the execution get breaks .
Can u show that relevant code ?
Re: Problem with QDialog class
right you are :o
(The error might be that (due to a missing Q_OBJECT in the class decl of MainWindow) the qobject_cast returns NULL.)
Re: Problem with QDialog class
Thanks for your kind replies .
With Regards,
Sudheer.