Results 1 to 20 of 20

Thread: Two ways, Which one is better?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2008
    Posts
    155
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanked 15 Times in 13 Posts

    Default Re: Two ways, Which one is better?

    Quote Originally Posted by wysota View Post
    What do you mean "better"? They are perfectly equivalent. The second one is less code to type in. If that counts as "better" then it's better.
    It also use one allocation less and has a slightly better chance to be exception save. I can't think of any situation where the first form is better.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Two ways, Which one is better?

    This is really an academic talk. One allocation more or less doesn't make a difference, Qt doesn't use exceptions so only your code can be throwing one so you should know how/where to catch it, etc. These two are practically equivalent, the stack based is simpler to type in which is completely meaningless as well. There is a potential situation when a heap based dialogue would lead to a memory leak but then read my post about "enlightened users"
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Is there any ways to check for nan inf and -inf in Qt?
    By aarelovich in forum Qt Programming
    Replies: 5
    Last Post: 2nd June 2016, 13:29
  2. Replies: 2
    Last Post: 16th July 2010, 16:03
  3. Model-view: Display items in different ways
    By taboom in forum Qt Programming
    Replies: 3
    Last Post: 13th August 2007, 20:05
  4. ways to exit appl.
    By whoops.slo in forum Newbie
    Replies: 1
    Last Post: 29th January 2007, 19:18

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.