Results 1 to 5 of 5

Thread: MSVSC++ QT and debugging

  1. #1
    Join Date
    Jun 2010
    Posts
    41
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default MSVSC++ QT and debugging

    I have built a similar project in C++ in Visual Studios. I am trying to convert as much of this project as I can into QT because the enviornment in which this application is needed has expanded to MAC OS.

    All of this compiles but I know there is an issue somewhere in the code becasue my query is not returning any rows. which brings the main issue. I can not for the life of me figure out how to set breakpoints in Visual Studios so I can see what is happening with my variables usename and password

    Theres no real reason for me to post my code because my real question is about debugging but I thought there might be something other than a breakpoint that could be done to check the variable so I included it :P

    Qt Code:
    1. #include "thewge.h"
    2. #include "ui_thewge.h"
    3. #include <QtGui/QApplication>
    4. #include <QSignalMapper>
    5. #include <QPushButton>
    6. #include <windows.h>
    7. #include <iostream>
    8. #include "md5.h"
    9. #include "mysql++.h"
    10.  
    11. TheWGE::TheWGE(QWidget *parent, Qt::WFlags flags)
    12. : QMainWindow(parent, flags)
    13. {
    14.  
    15. ui.setupUi(this);
    16.  
    17. QObject::connect(ui.LoginBtn, SIGNAL(clicked()), this, SLOT(login()));
    18.  
    19. }
    20.  
    21. TheWGE::~TheWGE()
    22. {
    23. //ui.usrLineEdit->clear();
    24. //ui.pwdLineEdit->clear();
    25. }
    26.  
    27. void TheWGE::login()
    28. {
    29.  
    30. if (ui.usrLineEdit->text().trimmed().isEmpty() )
    31. {
    32. ui.usrLineEdit->setFocus();
    33. }
    34. else if (ui.pwdLineEdit->text().trimmed().isEmpty() )
    35. {
    36. ui.pwdLineEdit->setFocus();
    37. }
    38.  
    39. mysqlpp::Connection con(false);
    40.  
    41. if (!con.connect("Database", "host", "username", "password"))
    42. {
    43. qApp->exit(0);
    44.  
    45. }
    46.  
    47. // Retrieve a subset of the sample stock table set up by resetdb
    48. mysqlpp::Query query = con.query();
    49.  
    50. QString Qstr1 = ui.usrLineEdit->text();
    51. QString Qstr2 = ui.pwdLineEdit->text();
    52.  
    53. char *acsUserName = new char[ Qstr1.length() + 1 ]; // + 1 for zero in the end of string
    54. memcpy( acsUserName, Qstr1.toUtf8().constData(),Qstr1.length() );
    55. char *acsPassword = new char[ Qstr2.length() + 1 ]; // + 1 for zero in the end of string
    56. memcpy( acsPassword, Qstr2.toUtf8().constData(), Qstr2.length() );
    57.  
    58.  
    59. query << "SELECT username, password FROM wge_db_user WHERE username = '" << acsUserName << "' and password = '" << md5(acsPassword) << "'";
    60.  
    61. mysqlpp::StoreQueryResult res = query.store();
    62. mysqlpp::Row row;
    63.  
    64. delete []acsUserName;
    65. delete []acsPassword;
    66.  
    67. if (res.num_rows() > 0)
    68. {
    69. qApp->exit(0);
    70. //goodlogin - show new form and hide this form
    71. }
    72. else
    73. {
    74.  
    75. //qApp->exit(0);
    76. //badlogin
    77. }
    78.  
    79. mysqlpp::Connection::thread_end();
    80.  
    81.  
    82. return;
    83. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MSVSC++ QT and debugging

    Visual studio has plenty of debugging tools. Put your cursor on a line of code and press F9. It should give you a breakpoint.

    Aside from that you should probably have the visual studio add-in installed.
    Last edited by franz; 24th June 2010 at 21:01. Reason: updated contents
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: MSVSC++ QT and debugging

    Make sure the debugging helper is installed.

    Make sure you are compiling in 'Debug' mode not 'Release' mode.

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

    harleyskater (25th June 2010)

  5. #4
    Join Date
    Jun 2010
    Posts
    41
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: MSVSC++ QT and debugging

    solution. after reinstalling 2005 and then installing 2008 and having the same problem. I ran across a page that said some things about how I should reconfigure with things like /ZI. I had posted the link earlier to that page, but my reply didn't post. after getting my break points to work! things got muchhhhhh easier and I have everything working now! thx

  6. #5
    Join Date
    Jun 2010
    Posts
    41
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: MSVSC++ QT and debugging

    i set up a new project and ran into the same problem and couldn't remember how to fix it, so I looked it up again.

    here it is incase someone else runs into this problem

    step1
    project properties->linker->debugging->generate debug info = YES
    step2
    project properties->c++->general->debug information->Program Database for Edit & Continue (/ZI)

Similar Threads

  1. debugging qt
    By freekill in forum Newbie
    Replies: 4
    Last Post: 26th November 2009, 05:21
  2. SXE key has not been set when debugging
    By learning_qt in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 24th September 2008, 08:59
  3. Debugging Qt
    By baray98 in forum Qt Programming
    Replies: 0
    Last Post: 7th May 2008, 00:16
  4. Debugging with gdb
    By SteM in forum Newbie
    Replies: 4
    Last Post: 9th August 2007, 14:40
  5. Debugging on Mac
    By rickbsgu in forum Qt Programming
    Replies: 3
    Last Post: 13th October 2006, 13:12

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.