I have tried to get the text form QLineEdit but I always get "" empty string.

Here is my code:

Database.h
Qt Code:
  1. #ifndef DATABASE_H
  2. #define DATABASE_H
  3.  
  4. #include <QObject>
  5. #include <QtSql>
  6. #include <QtGui>
  7. #include "MainWindow.h"
  8.  
  9. class Database : public QObject {
  10. Q_OBJECT
  11.  
  12. public:
  13. Database(QObject *parent = 0);
  14. ~Database();
  15.  
  16. MainWindow *Gui;
  17.  
  18. private:
  19. // Search Bar
  20. void prepareList();
  21. void updateListWidget();
  22.  
  23. // Records
  24. void setupDatabase();
  25. void setupModel();
  26. void setupMapper();
  27. void addMapping();
  28. void doSave();
  29.  
  30.  
  31. public:
  32.  
  33. private:
  34. // Records
  35. QSqlDatabase recordsDB;
  36. QSqlQuery recordsQuery;
  37. QSqlTableModel *recordsModel;
  38. QDataWidgetMapper *recordsMapper;
  39.  
  40. // Search Bar SQL Related Members
  41. QSqlDatabase searchDB;
  42. QSqlQuery searchQuery;
  43.  
  44. QStringList namesList;
  45. QStringList iqamasList;
  46. QStringList passportsList;
  47.  
  48. QStringList tempNamesList;
  49. QStringList tempIqamasList;
  50. QStringList tempPassportsList;
  51.  
  52. // Misc.
  53. enum CurrentStatus {Browsing, Adding, Editing};
  54.  
  55. private slots:
  56. // Search Bar
  57. void filterLists(QString currentNumber);
  58. void resetForm();
  59. void saveRecord();
  60.  
  61.  
  62. };
  63.  
  64. #endif // DATABASE_H
To copy to clipboard, switch view to plain text mode 

See lines: 10, 18 & 23

Part of (Database.cpp)
Qt Code:
  1. Database::Database(QObject *parent) : QObject(parent) {
  2. // The GUI
  3. Gui = new MainWindow;
  4. Gui->show();
  5.  
  6. // Records
  7. setupDatabase();
  8. setupModel();
  9. setupMapper();
  10. //saveRecord(); from here I get the text normally.
  11.  
  12. // Search Bar
  13. prepareList();
  14.  
  15. // Search Button Connection
  16. connect(Gui->ui->leSearch, SIGNAL(textChanged(QString)), this, SLOT(filterLists(QString)));
  17. connect(Gui->ui->actionNew, SIGNAL(triggered()), this, SLOT(resetForm()));
  18. connect(Gui->ui->actionSave, SIGNAL(triggered()), this, SLOT(saveRecord())); // from here I cannot get the text, I just get empty string "".
  19. } // Database(QObject *parent = 0)
  20.  
  21. // Slot
  22. void Database::saveRecord() {
  23. // if i call this slot through a connection "connect() see line 18" all these QLineEdits return empty string but actually the are filled with information.
  24. QString voucherTypeEst = QString(Gui->ui->radioEst->isChecked());
  25. QString voucherTypeCo = QString(Gui->ui->radioCo->isChecked());
  26. QString voucherTypeGov = QString(Gui->ui->radioGov->isChecked());
  27. QString firstARName = Gui->ui->leARFirstName->text();
  28. QString firstENName = Gui->ui->leENFirstName->text();
  29. QString iqamaNumber = Gui->ui->leIqamaNumber->text();
  30. QString nationality = Gui->ui->leNationality->text();
  31. QString job = Gui->ui->leJob->text();
  32. QString religion = Gui->ui->leReligion->text();
  33. QString passportNumber = Gui->ui->lePassportNumber->text();
  34. QString issuePlace = Gui->ui->leIssuePlace->text();
  35. QString entranceNumber = Gui->ui->leEntryNumber->text();
  36. QString entrancePort = Gui->ui->leEntryPort->text();
  37. QString iqamaDate = Gui->ui->leIqamaExpiryDate->text();
  38. QString birthdayDate = Gui->ui->leBirthdayDate->text();
  39. QString passportIssueDate = Gui->ui->lePassportIssueDate->text();
  40. QString passportExpiryDate = Gui->ui->lePassportExpiryDate->text();
  41. QString entryDate = Gui->ui->leEntryDate->text();
  42. QString voucherTypeSng = QString(Gui->ui->radioSng->isChecked());
  43. QString voucherName = Gui->ui->leCurrentVoucherName->text();
  44. QString voucherNumber = Gui->ui->leCurrentVoucherNumber->text();
  45. QString voucherAddress = Gui->ui->leCurrentVoucherAddress->text();
  46. QString voucherPhone = Gui->ui->leCurrentVoucherPhone->text();
  47. QString fatherARName = Gui->ui->leARFatherName->text();
  48. QString grandARName = Gui->ui->leARGrandName->text();
  49. QString familyARName = Gui->ui->leARFamilyName->text();
  50. QString fatherENName = Gui->ui->leENFatherName->text();
  51. QString grandENName = Gui->ui->leENGrandName->text();
  52. QString familyENName = Gui->ui->leENFamilyName->text();
  53. }
To copy to clipboard, switch view to plain text mode