Results 1 to 4 of 4

Thread: How to Handle new Qt?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question How to Handle new Qt?

    Dear Qtians!
    I have one question about new.
    Qt Code:
    1. //UI_DLGTEXTSCROLLER_H
    2. void setupUi(QDialog *dlgTextScroller)
    3. {
    4. .....
    5. ....
    6. pbOk = new QPushButton(dlgTextScroller);
    7. pbOk->setObjectName(QString::fromUtf8("pbOk"));
    8. pbOk->setGeometry(QRect(293, 197, 154, 27));
    9. ..........
    10. .........
    11. }
    To copy to clipboard, switch view to plain text mode 
    How a way pbOk handle error when bad allocation exists due to some reason.
    I am not seeing any try{ }catch{ } block for that.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

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

    Default Re: How to Handle new Qt?

    Quote Originally Posted by ashukla View Post
    How a way pbOk handle error when bad allocation exists due to some reason.
    Very simple - it doesn't. In most cases it would be a fatal error anyway...

  3. #3
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to Handle new Qt?

    Quote Originally Posted by wysota View Post
    Very simple - it doesn't. In most cases it would be a fatal error anyway...
    Then, I should use try{} and catch{} block for new or not in my classes.
    In some cases, if I does not use try{} catch{} for new and due to some reason object does not allocated and when I destroy object it gives segmentation fault.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

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

    Default Re: How to Handle new Qt?

    Quote Originally Posted by ashukla View Post
    Then, I should use try{} and catch{} block for new or not in my classes.
    It depends on you. If you can recover from a lack of memory and you are worried they might happen, feel free to do it.

    In some cases, if I does not use try{} catch{} for new and due to some reason object does not allocated and when I destroy object it gives segmentation fault.
    Most probably you have an error in your code (a dangling pointer perhaps) that is completely unrelated to exceptions thrown by operator new or lack of memory.

Similar Threads

  1. QSplitter handle invisible on Win32
    By para in forum Qt Programming
    Replies: 3
    Last Post: 23rd November 2010, 13:21
  2. OS/X how to get physical display handle
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 3rd January 2009, 19:51
  3. how can I get the QApplication handle by process ID in QT2
    By pencilren in forum Qt Programming
    Replies: 5
    Last Post: 28th August 2007, 20:10
  4. Override QSplitter to draw new handle
    By grogan in forum Qt Programming
    Replies: 4
    Last Post: 27th September 2006, 03:40
  5. Howto handle key-release with autorepeat key
    By gould75 in forum Qt Programming
    Replies: 2
    Last Post: 20th August 2006, 07:52

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.