I am trying to open a database through Qt . Here is the code.
Qt Code:
  1. inline bool createConnection()
  2. {
  3. QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
  4. db.setHostName("localhost");
  5. db.setDatabaseName("/home/pgdata/data1");
  6. db.setUserName("pgdata");
  7. db.setPassword("krajesh");
  8.  
  9. if (!db.open()) {
  10. QMessageBox::warning(0, QObject::tr("Database Error"),
  11. db.lastError().text());
  12. return false;
  13. }
  14. return true;
  15. }
To copy to clipboard, switch view to plain text mode 

it results in the error. FATAL: coulfd't coonnect to database /home/pgdata/data1.
/home/pgdata/data1 do exists. It is a cluster of database inside it i had created one with default name pgdata. but opening it also results in same name. I can acess and query over it using psql from command prompt. Also same code with QMYSQL works well.

quickNitin