Results 1 to 3 of 3

Thread: Abort QDialog in the constructor

  1. #1
    Join Date
    Jul 2009
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Abort QDialog in the constructor

    Hi,
    In a QDialog constructor I do that:

    Qt Code:
    1. try {
    2. QLabel *lbls = new QLabel[numLbls]; //numLbls is passed as parameter
    3. } catch(std::bad_alloc e) {
    4. // How I can abort this QDialog and avoid to be show?
    5. }
    To copy to clipboard, switch view to plain text mode 

    How I can abort this QDialog and avoid to be show?

  2. #2
    Join Date
    Jul 2009
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Abort QDialog in the constructor

    I don't understand. How can you add that try/catch block in QDialog constructor if it is Qt base class?

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

    Default Re: Abort QDialog in the constructor

    The constructor doesn't show the dialog. A call to show() or exec() does that. You can override it by reimplementing showEvent() and hiding the component there, by intercepting the call that shows the dialog or simply by not calling show() or exec() at all.
    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.


  4. The following user says thank you to wysota for this useful post:

    Tino (29th July 2009)

Similar Threads

  1. Replies: 6
    Last Post: 8th July 2009, 20:28
  2. adding QAction to QDialog is not working
    By sanjayshelke in forum Qt Programming
    Replies: 3
    Last Post: 13th August 2008, 09:39
  3. Resizing a QDialog to the content size
    By Nyphel in forum Qt Programming
    Replies: 8
    Last Post: 15th March 2007, 08:16
  4. QDialog: show() and exec() together in constructor?
    By Teuniz in forum Qt Programming
    Replies: 8
    Last Post: 28th February 2007, 11:43

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.