Results 1 to 7 of 7

Thread: QT MySQL

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2007
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QT MySQL

    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,

    Qt Code:
    1. #include <qapplication.h>
    2. #include "FarkData.h"
    3. #include <qsqldatabase.h>
    4.  
    5. int main( int argc, char ** argv )
    6. {
    7. QApplication a( argc, argv );
    8. QsqlDatabase *defaultDB=QsqlDatabase::addDatabase(“QMYSQL3”);
    9. defaultDB->setDatabaseName(“test”);
    10. defaultDB->setPassword(" “);
    11. defaultDB->setHostName(“localhost”);
    12.  
    13. if(defaultDB->open())
    14. {
    15. qWarning(“Database connection successful”);
    16. }
    17. else
    18. {
    19. qWarning(“Database connection failed”);
    20. return a.exec();
    21. }
    22.  
    23. MarkList w;
    24. w.show();
    25. a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
    26. return a.exec();
    27. }
    To copy to clipboard, switch view to plain text mode 

    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
    Last edited by wysota; 10th January 2007 at 10:47. Reason: reformatted to look better

Similar Threads

  1. Deploying with MySQL support under Windows
    By KShots in forum Installation and Deployment
    Replies: 1
    Last Post: 12th October 2006, 09:19
  2. Qt and MySQL Database Connection
    By shamik in forum Qt Programming
    Replies: 41
    Last Post: 6th October 2006, 12:48
  3. MYSQL Triggers??
    By allensr in forum General Programming
    Replies: 1
    Last Post: 2nd October 2006, 21:54
  4. Qt 4.1.4 & Mysql 5 on Linux x64
    By bothapn in forum Installation and Deployment
    Replies: 7
    Last Post: 4th August 2006, 13:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.