I need to connect to a postgree database 'testeDB' on my localhost

I tried the following code:


Qt Code:
  1. QSqlDatabase DB = (QSqlDatabase::addDatabase(QObject::tr("QODBC")));
  2. if ( &DB ) {
  3. DB.setDatabaseName( QObject::tr("testeDB"));
  4. DB.setUserName( QObject::tr("testUser") );
  5. DB.setPassword( QObject::tr("test") );
  6. DB.setHostName( QObject::tr("localhost"));
  7.  
  8. if ( DB.open() ) {
  9. qDebug()<< "OK!";
  10. } else {
  11. qDebug()<< DB.lastError().text() << "\n";
  12. }
  13. }
To copy to clipboard, switch view to plain text mode 

but I get an error when trying to open the connection, saying: (I`m translating it, so it may not be too accurate)
"Data Source name not found and QOBC3 default driver not specified: Not possible to connect."

Sooooo: how does I fix this?