Results 1 to 2 of 2

Thread: new operator

  1. #1
    Join Date
    Jul 2008
    Location
    Bangalore, India
    Posts
    24
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Question new operator

    Hi, Guys

    Could somebody give me an insight in this?
    what situation one needs to instantiate a QObject using the 'new' operator and without using a new operator

    Regards

    QTInfinity

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

    Default Re: new operator

    If the dialog should live longer than the scope exists when you create it, you must allocate it on the heap (using new).
    If you pass it to some other class and that class might try to delete it, you have to allocate it on the heap, too.

    HTH

  3. The following user says thank you to caduel for this useful post:

    QTInfinity (23rd December 2008)

Similar Threads

  1. std::max_element and overload operator()
    By mickey in forum General Programming
    Replies: 2
    Last Post: 8th September 2008, 18:28
  2. operator [] overloading
    By darksaga in forum General Programming
    Replies: 5
    Last Post: 8th April 2008, 15:27
  3. The -> Operator
    By keifer in forum Newbie
    Replies: 1
    Last Post: 11th March 2008, 02:24
  4. QString == Operator
    By ToddAtWSU in forum Qt Programming
    Replies: 1
    Last Post: 27th December 2006, 17:08
  5. template parameter and conversion operator
    By bitChanger in forum General Programming
    Replies: 7
    Last Post: 21st April 2006, 15:36

Tags for this Thread

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.