Results 1 to 10 of 10

Thread: Unhandled Exception Err

  1. #1
    Join Date
    Apr 2007
    Posts
    33
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Question Unhandled Exception Err

    Hi

    I was doing a tutorial http://sector.ynet.sk/qt4-tutorial/m...plication.html
    and I did just some minor changes to the code.
    After running the program I got an error. Seems that I am pointing to somewhere illegal or something! I attached the screen shot of the Error here.
    Could you please tell me what is the reason of such errors?
    Is it called runtime error or something else?!

    Thx
    Attached Images Attached Images

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unhandled Exception Err

    In general, the reason for these errors is an uninitialized pointer.
    The error is actually a memory violation resulted when the program tried to read from an unallocated memory address.

    From what I have seen in the call stack, your problem is in a connect statement, in the constructor of myQtApp.
    You are passing an invalid pointer as the sender.


    Regards

  3. #3
    Join Date
    Apr 2007
    Posts
    33
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Unhandled Exception Err

    Quote Originally Posted by marcel View Post
    In general, the reason for these errors is an uninitialized pointer.
    The error is actually a memory violation resulted when the program tried to read from an unallocated memory address.

    From what I have seen in the call stack, your problem is in a connect statement, in the constructor of myQtApp.
    You are passing an invalid pointer as the sender.


    Regards

    These are the connects I am using in the program. Should the problem be by those pushButton_##s?

    Qt Code:
    1. myQtApp::myQtApp(QWidget *parent, Qt::WFlags flags)
    2. : QWidget(parent, flags)
    3.  
    4. {
    5. ui.setupUi(this);
    6. connect( pushButton_Browse,SIGNAL(clicked()),this,SLOT(getPath()));
    7. connect( pushButton_DoSomething,SIGNAL( clicked() ),this, SLOT( doSomething() ) );
    8. connect( pushButton_Clear, SIGNAL(clicked()),this,SLOT(clear() ) );
    9. connect( pushButton_About, SIGNAL(clicked()), this, SLOT(about()));
    10. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unhandled Exception Err

    But where do you allocate pushButton_*?
    They first have to be created.
    So just do something like:
    Qt Code:
    1. pushButton_Browse = new QPushButton("Browse", this);
    To copy to clipboard, switch view to plain text mode 

    Regards

  5. #5
    Join Date
    Apr 2007
    Posts
    33
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Unhandled Exception Err

    Quote Originally Posted by marcel View Post
    But where do you allocate pushButton_*?
    They first have to be created.
    So just do something like:
    Qt Code:
    1. pushButton_Browse = new QPushButton("Browse", this);
    To copy to clipboard, switch view to plain text mode 

    Regards
    I used Qt-Designer to make the Ui. Isn't it correct that when making this Ui with drag and drop and then naming it, we actually create this Object off the heap?

    Thx.
    Attached Images Attached Images

  6. #6
    Join Date
    Apr 2007
    Posts
    33
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Unhandled Exception Err

    Quote Originally Posted by marcel View Post
    But where do you allocate pushButton_*?
    They first have to be created.
    So just do something like:
    Qt Code:
    1. pushButton_Browse = new QPushButton("Browse", this);
    To copy to clipboard, switch view to plain text mode 

    Regards

    They are in ui_myqtapp.h.


    Qt Code:
    1. #include <QtGui/QLabel>
    2. #include <QtGui/QLineEdit>
    3. #include <QtGui/QPushButton>
    4. #include <QtGui/QSpinBox>
    5. #include <QtGui/QTextBrowser>
    6. #include <QtGui/QWidget>
    7.  
    8. class Ui_myQtAppClass
    9. {
    10. public:
    11. QSpinBox *spinBox_2;
    12. QSpinBox *spinBox;
    13. QLabel *label;
    14. QLineEdit *lineEdit;
    15. QLabel *label_2;
    16. QCheckBox *checkBox;
    17. QComboBox *comboBox;
    18. QLabel *label_3;
    19. QPushButton *pushButton_DoSomething;
    20. QPushButton *pushButton_Clear;
    21. QPushButton *pushButton_About;
    22. QTextBrowser *textBrowser;
    23. QPushButton *pushButton_Browse;
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unhandled Exception Err

    I suggest to debug the myQtApp constructor.

    Put a breakpoint in the first line (ui.setupUi(this)) - press F9 on that line.
    Hit F5 to start debugging.
    While you step over look at what addresses the three pointers have ( the QPushButtons ).

    Check if either one of them is invalid.

    Regards

  8. The following user says thank you to marcel for this useful post:

    Masih (24th July 2007)

  9. #8
    Join Date
    Apr 2007
    Posts
    33
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Lightbulb Re: Unhandled Exception Err

    Quote Originally Posted by marcel View Post
    I suggest to debug the myQtApp constructor.

    Put a breakpoint in the first line (ui.setupUi(this)) - press F9 on that line.
    Hit F5 to start debugging.
    While you step over look at what addresses the three pointers have ( the QPushButtons ).

    Check if either one of them is invalid.

    Regards
    Hi Marcel,

    I did what you have recommended. Actually I didn't understand what the problem source could be. I just removes the "ui." from
    Qt Code:
    1. ui.setupUi(this)
    To copy to clipboard, switch view to plain text mode 
    and then everything was fine and no error happened!
    first , Can you explain me why this ui. was the problem source?!
    and second, do you have any source explaining the debugging techniques in MVSC ?
    Thanks a lot in advance.
    Last edited by Masih; 25th July 2007 at 20:19. Reason: spelling error

  10. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Unhandled Exception Err

    There are two suggested ways of using designer components:

    To me it sounds like these two approaches are getting mixed up.
    J-P Nurmi

  11. The following user says thank you to jpn for this useful post:

    Masih (25th July 2007)

  12. #10
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unhandled Exception Err

    Can you explain me why this ui. was the problem source?!
    I think jpn's post explains it.

    do you have any source explaining the debugging techniques in MVSC ?
    Not really. It's everything pretty straightforward and it is depending on what you're looking for.
    The most important are:
    F10 - Step over
    F11 - Step in
    F5 - Continue.
    Keep your eyes on the Autos, Locals, Call stack and Threads tabs.
    And with Qt it is very useful to examine the Output tab since all debugging messages go there.

    You can also add watches.

    Another useful thing is the Quick Watch window - just position the cursor on a variable and press Alt-Q. Very good for arrays, classes, structs.

    I guess you'll discover more of them as you proceed.

    Regards

  13. The following user says thank you to marcel for this useful post:

    Masih (25th July 2007)

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 10:49
  2. Exception handling in Qt 4.2.2
    By vishal.chauhan in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2007, 10:47
  3. c++, placement delete upon exception
    By stinos in forum General Programming
    Replies: 6
    Last Post: 31st October 2006, 16:38
  4. Qt's Exception Handling
    By bruce1007 in forum Qt Programming
    Replies: 2
    Last Post: 13th June 2006, 10:30
  5. Exceptions and qApp->processEvents()
    By mcostalba in forum Qt Programming
    Replies: 3
    Last Post: 8th January 2006, 18:06

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.