sabeeshcs
10th January 2007, 09:04
Hello,
I am a new commer in QT. I am using QT 3.3.4, MYSQL 4.1.11 and OS is Linux (Fedora Core 4 ). I wand to create a simple programe in QT ( Linux -Fedora Core 4 Version ). I designed a form and wite the code. The programe is working. After that I had try to connect this programe with MYSQL, then it is not working, How can I connect my programme with MYSQL?
I give some lines in my programme, that the following,
#include <qapplication.h>
#include "FarkData.h"
#include <qsqldatabase.h>
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
QsqlDatabase *defaultDB=QsqlDatabase::addDatabase(“QMYSQL 3â€);
defaultDB->setDatabaseName(“testâ€);
defaultDB->setPassword(" “);
defaultDB->setHostName(“localhostâ€);
if(defaultDB->open())
{
qWarning(“Database connection successfulâ€);
}
else
{
qWarning(“Database connection failedâ€);
return a.exec();
}
MarkList w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
}
after this code i give a commend,
qmake -o Makefile mark.pro
Then no error displayed, then i give the command,
make
Then a list of error is display, the error is
/usr/lib/qt-3.3/bin/uic FarkData.ui -o .ui/FarkData.h
g++ -c -pipe -Wall -W -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4 -fasynchronous-unwind-tables -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/lib/qt-3.3/mkspecs/default -I. -I/usr/lib/qt-3.3/include -I.ui/ -I. -I.moc/ -o .obj/main.o main.cpp
main.cpp:9: error: stray ‘\226’ in program
main.cpp:9: error: stray ‘\128’ in program
main.cpp:9: error: stray ‘\156’ in program
main.cpp:9: error: stray ‘\226’ in program
main.cpp:9: error: stray ‘\128’ in program
main.cpp:9: error: stray ‘\157’ in program
main.cpp:11: error: stray ‘\226’ in program
main.cpp:11: error: stray ‘\128’ in program
main.cpp:11: error: stray ‘\156’ in program
main.cpp:11: error: stray ‘\226’ in program
main.cpp:11: error: stray ‘\128’ in program
main.cpp:11: error: stray ‘\157’ in program
main.cpp:12: error: stray ‘\226’ in program
main.cpp:12: error: stray ‘\128’ in program
main.cpp:12: error: stray ‘\156’ in program
main.cpp:12: error: stray ‘\226’ in program
main.cpp:12: error: stray ‘\128’ in program
main.cpp:12: error: stray ‘\156’ in program
main.cpp:13: error: stray ‘\226’ in program
main.cpp:13: error: stray ‘\128’ in program
main.cpp:13: error: stray ‘\156’ in program
main.cpp:13: error: stray ‘\226’ in program
main.cpp:13: error: stray ‘\128’ in program
main.cpp:13: error: stray ‘\157’ in program
main.cpp:17: error: stray ‘\226’ in program
main.cpp:17: error: stray ‘\128’ in program
main.cpp:17: error: stray ‘\156’ in program
main.cpp:17: error: stray ‘\226’ in program
main.cpp:17: error: stray ‘\128’ in program
main.cpp:17: error: stray ‘\157’ in program
main.cpp:21: error: stray ‘\226’ in program
main.cpp:21: error: stray ‘\128’ in program
main.cpp:21: error: stray ‘\156’ in program
main.cpp:21: error: stray ‘\226’ in program
main.cpp:21: error: stray ‘\128’ in program
main.cpp:21: error: stray ‘\157’ in program
.ui/FarkData.h:47: error: ISO C++ forbids declaration of ‘QSqlDatabase’ with no type
/usr/lib/qt-3.3/include/qsqldatabase.h:63: warning: ‘class QSqlDriverCreatorBase’ has virtual functions but non-virtual destructor
main.cpp: In function ‘int main(int, char**)’:
main.cpp:9: error: ‘QsqlDatabase’ was not declared in this scope
main.cpp:9: error: ‘defaultDB’ was not declared in this scope
main.cpp:9: error: ‘QsqlDatabase’ is not a class or namespace
main.cpp:9: error: ‘QMYSQL3’ was not declared in this scope
main.cpp:9: error: ‘addDatabase’ was not declared in this scope
main.cpp:11: error: ‘test’ was not declared in this scope
main.cpp:13: error: ‘localhost’ was not declared in this scope
main.cpp:17: error: ‘Database’ was not declared in this scope
main.cpp:21: error: ‘Database’ was not declared in this scope
make: *** [.obj/main.o] Error 1
What to do ?
please help me...........
Sabeesh
I am a new commer in QT. I am using QT 3.3.4, MYSQL 4.1.11 and OS is Linux (Fedora Core 4 ). I wand to create a simple programe in QT ( Linux -Fedora Core 4 Version ). I designed a form and wite the code. The programe is working. After that I had try to connect this programe with MYSQL, then it is not working, How can I connect my programme with MYSQL?
I give some lines in my programme, that the following,
#include <qapplication.h>
#include "FarkData.h"
#include <qsqldatabase.h>
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
QsqlDatabase *defaultDB=QsqlDatabase::addDatabase(“QMYSQL 3â€);
defaultDB->setDatabaseName(“testâ€);
defaultDB->setPassword(" “);
defaultDB->setHostName(“localhostâ€);
if(defaultDB->open())
{
qWarning(“Database connection successfulâ€);
}
else
{
qWarning(“Database connection failedâ€);
return a.exec();
}
MarkList w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
}
after this code i give a commend,
qmake -o Makefile mark.pro
Then no error displayed, then i give the command,
make
Then a list of error is display, the error is
/usr/lib/qt-3.3/bin/uic FarkData.ui -o .ui/FarkData.h
g++ -c -pipe -Wall -W -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4 -fasynchronous-unwind-tables -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/lib/qt-3.3/mkspecs/default -I. -I/usr/lib/qt-3.3/include -I.ui/ -I. -I.moc/ -o .obj/main.o main.cpp
main.cpp:9: error: stray ‘\226’ in program
main.cpp:9: error: stray ‘\128’ in program
main.cpp:9: error: stray ‘\156’ in program
main.cpp:9: error: stray ‘\226’ in program
main.cpp:9: error: stray ‘\128’ in program
main.cpp:9: error: stray ‘\157’ in program
main.cpp:11: error: stray ‘\226’ in program
main.cpp:11: error: stray ‘\128’ in program
main.cpp:11: error: stray ‘\156’ in program
main.cpp:11: error: stray ‘\226’ in program
main.cpp:11: error: stray ‘\128’ in program
main.cpp:11: error: stray ‘\157’ in program
main.cpp:12: error: stray ‘\226’ in program
main.cpp:12: error: stray ‘\128’ in program
main.cpp:12: error: stray ‘\156’ in program
main.cpp:12: error: stray ‘\226’ in program
main.cpp:12: error: stray ‘\128’ in program
main.cpp:12: error: stray ‘\156’ in program
main.cpp:13: error: stray ‘\226’ in program
main.cpp:13: error: stray ‘\128’ in program
main.cpp:13: error: stray ‘\156’ in program
main.cpp:13: error: stray ‘\226’ in program
main.cpp:13: error: stray ‘\128’ in program
main.cpp:13: error: stray ‘\157’ in program
main.cpp:17: error: stray ‘\226’ in program
main.cpp:17: error: stray ‘\128’ in program
main.cpp:17: error: stray ‘\156’ in program
main.cpp:17: error: stray ‘\226’ in program
main.cpp:17: error: stray ‘\128’ in program
main.cpp:17: error: stray ‘\157’ in program
main.cpp:21: error: stray ‘\226’ in program
main.cpp:21: error: stray ‘\128’ in program
main.cpp:21: error: stray ‘\156’ in program
main.cpp:21: error: stray ‘\226’ in program
main.cpp:21: error: stray ‘\128’ in program
main.cpp:21: error: stray ‘\157’ in program
.ui/FarkData.h:47: error: ISO C++ forbids declaration of ‘QSqlDatabase’ with no type
/usr/lib/qt-3.3/include/qsqldatabase.h:63: warning: ‘class QSqlDriverCreatorBase’ has virtual functions but non-virtual destructor
main.cpp: In function ‘int main(int, char**)’:
main.cpp:9: error: ‘QsqlDatabase’ was not declared in this scope
main.cpp:9: error: ‘defaultDB’ was not declared in this scope
main.cpp:9: error: ‘QsqlDatabase’ is not a class or namespace
main.cpp:9: error: ‘QMYSQL3’ was not declared in this scope
main.cpp:9: error: ‘addDatabase’ was not declared in this scope
main.cpp:11: error: ‘test’ was not declared in this scope
main.cpp:13: error: ‘localhost’ was not declared in this scope
main.cpp:17: error: ‘Database’ was not declared in this scope
main.cpp:21: error: ‘Database’ was not declared in this scope
make: *** [.obj/main.o] Error 1
What to do ?
please help me...........
Sabeesh