Using Qt-4.1.0 and MySQL 5.0.18
After trying to compile this code:
#include <QApplication>
#include <QtSql>
#include <iostream>
using namespace std;
int main(int argc, char * argv[])
{
cout << "Testing Qt and the connection to the database\n";
QSqlDatabase db = QSqlDatabase::addDatabase("QMySQL");
db.setHostName = ("localhost");
return 1;
}
I get this error:
s/linux-g++ -I. -I../../../include/QtCore -I../../../include/QtGui -I../../../include/QtSql -I../../../include -I. -I. -I. -o qtDatabase.o qtDatabase.cpp
qtDatabase.cpp: In function ‘int main(int, char**)’:
qtDatabase.cpp:11: error: invalid use of member (did you forget the ‘&’ ?)
qtDatabase.cpp: At global scope:
qtDatabase.cpp:6: warning: unused parameter ‘argc’
qtDatabase.cpp:6: warning: unused parameter ‘argv’
make: *** [qtDatabase.o] Error 1
What is wrong with ---- db.setHostName = ("localhost"); ---- ?
Bookmarks