I am working on a QT program, its my first QT C++ app and I am using MSVS 2008 as my IDE.

My app runs great when I debug in Release mode and it takes a screenshot and puts it in the apps DIR. Now I want to pass it to a friend to make sure it works on Vista. So I go to test it on my comp outside of the IDE by just clicking the generated exe in my Apps Release folder and it starts up and all the code is working great with no errors except the screenshots. It wasnt generating errors but it also wasn't taking the screenshots even though I know that section of code is being hit.

I tried to switch from an implicit app path for the scrrenshot file, to an explicit C:\test.jpeg and it works again within the IDE and not outside of it. Im at a loss right now for why this would happen. I also deleted my Release folder and recompiling to make sure it was refreshing all the files.

Qt Code:
  1. #include "thewge.h"
  2. #include "ui_thewge.h"
  3. #include <QtGui/QApplication>
  4. #include <QSignalMapper>
  5. #include <QPushButton>
  6. #include <QWidget>
  7. #include <QTimer>
  8. #include <QDesktopWidget>
  9. #include <QPixmap>
  10. #include <windows.h>
  11. #include <iostream>
  12. #include "md5.h"
  13. #include "mysql++.h"
  14.  
  15. TheWGE::TheWGE(QWidget *parent, Qt::WFlags flags)
  16. : QMainWindow(parent, flags)
  17. {
  18.  
  19. ui.setupUi(this);
  20.  
  21. QObject::connect(ui.LoginBtn, SIGNAL(clicked()), this, SLOT(login()));
  22.  
  23. }
  24.  
  25. TheWGE::~TheWGE()
  26. {
  27. //ui.usrLineEdit->clear();
  28. //ui.pwdLineEdit->clear();
  29. }
  30.  
  31. void TheWGE::login()
  32. {
  33.  
  34. if (ui.usrLineEdit->text().trimmed().isEmpty() )
  35. {
  36. ui.usrLineEdit->setFocus();
  37. }
  38. else if (ui.pwdLineEdit->text().trimmed().isEmpty() )
  39. {
  40. ui.pwdLineEdit->setFocus();
  41. }
  42.  
  43. mysqlpp::Connection con(false);
  44.  
  45. if (!con.connect("db", "host", "user", "pass"))
  46. {
  47. qApp->exit(0);
  48.  
  49. }
  50.  
  51. // Query Mysql
  52. mysqlpp::Query query = con.query();
  53.  
  54. QString Qstr1 = ui.usrLineEdit->text();
  55. QString Qstr2 = ui.pwdLineEdit->text();
  56.  
  57. std::string acsUserName2 = Qstr1.toUtf8().data();
  58. std::string acsPassword2 = Qstr2.toUtf8().data();
  59.  
  60.  
  61. query << "SELECT username, password FROM wge_db_user WHERE username = '" << acsUserName2 << "' and password = '" << md5(acsPassword2) << "'";
  62.  
  63. mysqlpp::StoreQueryResult res = query.store();
  64. mysqlpp::Row row;
  65.  
  66.  
  67. if (res.num_rows() > 0)
  68. {
  69. //goodlogin - show new form and hide this form
  70. shootScreen();
  71. QTimer::singleShot (60000, this, SLOT(shootScreen()));
  72. }
  73. else
  74. {
  75. //badlogin- code more here laterrrrrrrrr
  76. qApp->exit(0);
  77.  
  78. }
  79.  
  80. mysqlpp::Connection::thread_end();
  81.  
  82.  
  83. return;
  84. }
  85.  
  86. void TheWGE::shootScreen()
  87. {
  88.  
  89. QPixmap originalPixmap;
  90. originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId());
  91.  
  92. originalPixmap.save("test.jpeg");
  93.  
  94. }
To copy to clipboard, switch view to plain text mode