I had a small problem and so, I was playing a lttle bit with the source.

Can anobody tell my, why in the following code dbMandant.open() returns true, even if there is no host, no databaseName specified??

Qt Code:
  1. QSqlDatabase dbMandant = QSqlDatabase::addDatabase( dbDriver, "mandant" );
  2.  
  3. //dbMandant.setHostName( dbHost );
  4. //dbMandant.setDatabaseName( dbName );
  5. dbMandant.setUserName( dbUser );
  6. dbMandant.setPassword( dbPasswd );
  7. //dbMandant.setPort( dbPort.toInt() );
  8.  
  9. qDebug() << dbMandant;
  10. qDebug() << dbMandant.open();
To copy to clipboard, switch view to plain text mode 

Here ist the output from qDebug:

QSqlDatabase(driver=""QMYSQL"", database="""", host="""", port=-1, user=""root"", open=false)
true

The manual says:
bool QSqlDatabase:pen ()
opens the database connection using the current connection values. Returns true on success; otherwise returns false.

I don't have a connection value for setDatabaseName, why open() returns true?

Regards Guenther