First : QSqlDatabase::open returns bool value - test it.
Second : if open() == false use QSqlDatabase::lastError() to check what is wrong.