Hi there,

I am going crazy about a simple thing I guess. I seeked broadly all over the QSQL pages to find the answer; but..

My goal :
Linking my Qt interface fields to my postgresql database.
I read about QDataWidgetMapper but it doesn't fills my needs.
------------------------------------------------------------------------------
Context :

We will use my postgresql 's testing table.

There is
- a schema zero
- a table one
- a column two
------------------------------------------------------------------------------
The code I have :
I use Qt Creator and below is the code :

Gestion.pro
Qt Code:
  1. QT += core gui
  2. QT += sql
  3. TARGET = Gestion
  4. TEMPLATE = app
  5.  
  6.  
  7. SOURCES += main.cpp\
  8. mainwindow.cpp
  9.  
  10. HEADERS += mainwindow.h
  11.  
  12. FORMS += mainwindow.ui
To copy to clipboard, switch view to plain text mode 

My main.cpp
Qt Code:
  1. #include <QtGui/QApplication>
  2. #include <QCoreApplication>
  3. #include <QtSql/QtSql>
  4. #include <QtSql/QSqlDatabase>
  5. #include <QtSql/QSqlQuery>
  6. #include <iostream>
  7. #include "mainwindow.h"
  8.  
  9. #define q2c(string) string.toStdString()
  10.  
  11.  
  12. int main(int argc, char *argv[])
  13. {
  14. QApplication a(argc, argv);
  15.  
  16. QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
  17. db.setHostName("localhost");
  18. db.setPort(5433);
  19. db.setDatabaseName("totof");
  20. db.setUserName("postgres");
  21. db.setPassword("password");
  22.  
  23. db.open();
  24.  
  25. MainWindow w;
  26. w.show();
  27.  
  28. return a.exec();
  29. }
To copy to clipboard, switch view to plain text mode 

and the mainwindows.cpp
Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3.  
  4. MainWindow::MainWindow(QWidget *parent) :
  5. QMainWindow(parent),
  6. ui(new Ui::MainWindow)
  7. {
  8. ui->setupUi(this);
  9.  
  10. mapper = new QDataWidgetMapper(this);
  11.  
  12. mapper->addMapping(ui->lineEdit,0);
  13. }
  14.  
  15.  
  16. MainWindow::~MainWindow()
  17. {
  18. delete ui;
  19. }
To copy to clipboard, switch view to plain text mode 

How could I tell the lineEdit to insert what i type in, into zero.un of my postgresql database ?

I rely on you, since i am not good enough to make it on my own,

LeHibou