Results 1 to 6 of 6

Thread: Check has created with new

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Dec 2009
    Posts
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Check has created with new

    If you intend there to be only one Tahede instance in your program, please look at the singleton pattern. If you want to have a delayed construction of a member variable, you need to initialize it to 0 first. Perhaps the following would work (might not compile verbatim, inline code for a brief example):
    Qt Code:
    1. class MyObject : public QObject
    2. {
    3. public:
    4. MyObject() : _tahede(0) {}
    5.  
    6. void doExec() {
    7. tahede()->exec();
    8. }
    9.  
    10. protected:
    11. Tahede* tahede() {
    12. if(!_tahede)
    13. _tahede = new Tahede(this);
    14. return _tahede;
    15. }
    16.  
    17. private:
    18. Tadede* _tahede;
    19. };
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to toreo for this useful post:

    wirasto (11th December 2009)

Similar Threads

  1. Help: How to save Check box state
    By Garibalde in forum Qt Programming
    Replies: 4
    Last Post: 1st July 2009, 20:24
  2. Trouble while viewing a created a toolbar!!
    By aditya.kaole in forum Qt Programming
    Replies: 1
    Last Post: 6th April 2009, 21:04
  3. Replies: 0
    Last Post: 2nd May 2008, 07:57
  4. How to check a file for changes since last save
    By nmather in forum General Programming
    Replies: 2
    Last Post: 21st April 2007, 23:43
  5. Line not being created
    By Kapil in forum Newbie
    Replies: 4
    Last Post: 30th March 2006, 06:49

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
  •  
Qt is a trademark of The Qt Company.