Results 1 to 3 of 3

Thread: wanted to re-instantiate two classes from a class

  1. #1
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default wanted to re-instantiate two classes from a class

    Qt Code:
    1. #include "Progress.h"
    2. #include "TrainNavigation.h"
    3. ..
    4. TrainingUI::TrainingUI()
    5. {
    6.  
    7. progress = new Progress(this);
    8. progress->setGeometry(30,250,350,350);
    9.  
    10. navigate = new TrainNavigation(this);
    11. navigate->setGeometry(30,20,350,200);
    12.  
    13. }
    14.  
    15. void TrainingUI::resetTraining()
    16. {
    17. delete progress;
    18. delete navigate;
    19. // here i wanted to reinstate progress and navigate such that that it should be logical and efficient
    20. }
    To copy to clipboard, switch view to plain text mode 

    i tried to put the code in the constructor in a static member function and tried to call that function from constructor and resetTraining() ..but it didnt worked..any help...e
    Last edited by wysota; 22nd August 2008 at 10:09. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: wanted to re-instantiate two classes from a class

    Quote Originally Posted by salmanmanekia View Post
    i tried to put the code in the constructor in a static member function
    You can't access member variables in static methods.

  3. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: wanted to re-instantiate two classes from a class

    maybe the easiest way is: create a method in both classes like clear() or init() which will set initial state of an object and refuse from physically deleting of objects?

Similar Threads

  1. class QHBoxLayout
    By csvivek in forum Installation and Deployment
    Replies: 2
    Last Post: 10th April 2008, 07:57
  2. How to use Signal through direct connection
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 14th December 2007, 07:07

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.