With just the code i post here: http://www.qtcentre.org/threads/3533...-work-properly i can use the debug but now i add some functions to connect to a DB and insert data on it. Now i can's use the debug, i set breakpoins but the debugger never stop on it.

Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QtGui/QMainWindow>
  5. #include <QProgressBar>
  6. #include <QSqlDatabase>
  7.  
  8. class MainWindow : public QMainWindow
  9. {
  10. Q_OBJECT
  11.  
  12. public:
  13. MainWindow(QWidget *parent = 0);
  14. ~MainWindow();
  15.  
  16. public slots:
  17. void test();
  18. void abortButtonClicked();
  19.  
  20. private:
  21. QProgressBar *progress;
  22. bool abortButtonFlag;
  23. };
  24.  
  25. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include "mainwindow.h"
  2. #include <QDebug>
  3. #include <QString>
  4. #include <QDir>
  5. #include <QFileDialog>
  6. #include <QMessageBox>
  7. #include <QLabel>
  8. #include <QProgressBar>
  9. #include <QLayout>
  10. #include <QVBoxLayout>
  11. #include <QTimer>
  12. #include <QCoreApplication>
  13. #include <QPushButton>
  14. #include <QSqlDatabase>
  15. #include <QSqlQuery>
  16. #include <QSqlError>
  17.  
  18. MainWindow::MainWindow(QWidget *parent)
  19. : QMainWindow(parent)
  20. {
  21.  
  22. QVBoxLayout *layout = new QVBoxLayout;
  23. progress = new QProgressBar;
  24. layout->addWidget(progress);
  25.  
  26. QPushButton *abortButton = new QPushButton("Abort");
  27. connect(abortButton, SIGNAL(clicked()), this, SLOT(abortButtonClicked()));
  28. layout->addWidget(abortButton);
  29.  
  30. QWidget *w=new QWidget();
  31. w->setLayout(layout);
  32. this->setCentralWidget(w);
  33.  
  34. abortButtonFlag = new bool;
  35. abortButtonFlag = false;
  36.  
  37. QTimer::singleShot(100, this, SLOT(test()));
  38.  
  39. }
  40.  
  41. MainWindow::~MainWindow()
  42. {
  43.  
  44. }
  45.  
  46. void MainWindow::test(){
  47.  
  48. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
  49. db.setDatabaseName("thomsonkeysDB");
  50.  
  51. if (db.open()) {
  52. if (db.tables().indexOf("thomsonkeys") == -1) {
  53. QSqlQuery query(db);
  54. query.prepare("CREATE TABLE thomsonkeys (ssid VARCHAR(6), pass VARCHAR(10))");
  55. if (!query.exec())
  56. qCritical() << query.lastError();
  57. }
  58. } else {
  59. qCritical() << db.lastError();
  60. }
  61.  
  62. QString dir = QFileDialog::getOpenFileName(this, tr("Select Text File"),"",tr("Text (*.txt)"));
  63. QFile f(dir);
  64. f.open(QIODevice::ReadOnly);
  65. if(f.isOpen())
  66. {
  67. int fileSize=f.size();
  68. int step=fileSize/100;
  69. int bytesProcessed=0;
  70. QString line;
  71. QSqlQuery query(db);
  72. progress->setMaximum(fileSize);
  73. progress->setValue(bytesProcessed);
  74. while ((not f.atEnd()) & (not abortButtonFlag)){
  75. line = f.readLine().data();
  76. bytesProcessed+= line.size();
  77. list = line.split(":");
  78. query.exec("insert into thomsonkeys values('"+list.at(0)+"', '"+list.at(1)+"')");
  79. if (bytesProcessed%step<=20){
  80. progress->setValue(bytesProcessed);
  81. QCoreApplication::processEvents();
  82. }
  83. }
  84. f.close();
  85. db.close();
  86. progress->setValue(bytesProcessed);
  87. progress->setEnabled(false);
  88. }
  89. else
  90. {
  91. QMessageBox::warning(this,"Error","No file selected!");
  92. }
  93. }
  94.  
  95. void MainWindow::abortButtonClicked(){
  96. abortButtonFlag=true;
  97. }
To copy to clipboard, switch view to plain text mode