Results 1 to 5 of 5

Thread: Problem with QDialog class

  1. #1
    Join Date
    Aug 2008
    Posts
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default 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

    Qt Code:
    1. MainWindow *omans = qobject_cast<MainWindow *>(parentWidget());
    2. omans->natimer->stop();
    To copy to clipboard, switch view to plain text mode 

    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.

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QDialog class

    @Caduel, his class is MainWindow, not QMainWindow.

    @Sudheer
    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 ?

  4. #4
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem with QDialog class

    right you are

    (The error might be that (due to a missing Q_OBJECT in the class decl of MainWindow) the qobject_cast returns NULL.)

  5. #5
    Join Date
    Aug 2008
    Posts
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Problem with QDialog class

    Thanks for your kind replies .

    With Regards,
    Sudheer.

Similar Threads

  1. html parsing class problem
    By yagabey in forum Qt Programming
    Replies: 4
    Last Post: 22nd December 2008, 18:52
  2. Thread Problem
    By qball2k5 in forum Qt Programming
    Replies: 2
    Last Post: 12th April 2006, 17:31
  3. virtual overloaded functions and base class function call...
    By nouknouk in forum General Programming
    Replies: 7
    Last Post: 11th March 2006, 21:26
  4. Replies: 16
    Last Post: 7th March 2006, 15:57
  5. Compilation problem, don't know why
    By yellowmat in forum Newbie
    Replies: 6
    Last Post: 2nd March 2006, 15:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.