Results 1 to 2 of 2

Thread: SQLITE include error

  1. #1
    Join Date
    Mar 2009
    Posts
    116
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default SQLITE include error

    I m using Qt 4.4.3 and I have installed SQLite Maestro (windows OS).

    Now I want to connect to DB ,


    I have started with some code but getting errroe

    Header file is
    Qt Code:
    1. #ifndef DB_TRANS_H
    2. #define DB_TRANS_H
    3.  
    4.  
    5.  
    6.  
    7. class DB_TRANS
    8. {
    9. public:
    10. DB_TRANS();
    11. }
    12.  
    13.  
    14. #endif
    To copy to clipboard, switch view to plain text mode 

    and cpp file is

    Qt Code:
    1. #include "DB_TRANS.h"
    2. #include <QMessageBox>
    3. #include <QSqlDatabase>
    4. #include <QSqlQuery>
    5. #include <QSqlError>
    6.  
    7.  
    8.  
    9. DB_TRANS::DB_TRANS()
    10. {
    11. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    12. db.setHostName("localhost");
    13. db.setDatabaseName("SE01_DB");
    14. // db.setUserName("mojito");
    15. db.setPassword("SE01");
    16. bool ok = db.open();
    17.  
    18. if(!ok){
    19. QMessageBox::critical( this, "SE01_DB Database Error",
    20. "Could not connect to the database!\n"
    21. "\n"
    22. "Reported error:\n"
    23. +db.lastError().driverText()+"\n"
    24. +db.lastError().databaseText()+"\n"
    25. +db.databaseName()+"\n");
    26. }
    27. }
    To copy to clipboard, switch view to plain text mode 


    these 2 files I have included in my .PRO file.
    also included below line in PRO file
    Qt Code:
    1. QT += sql
    To copy to clipboard, switch view to plain text mode 
    But when I compile the program I get below errors

    Qt Code:
    1. In file included from C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stddef.h:6,
    2. from ../../../include/QtCore/../../src/corelib/global/qglobal.h:41,
    3. from ../../../include/QtCore/qglobal.h:1,
    4. from ../../../include/QtCore/../../src/corelib/global/qnamespace.h:41,
    5. from ../../../include/QtCore/qnamespace.h:1,
    6. from ../../../include/QtCore/../../src/corelib/kernel/qobjectdefs.h:41,
    7. from ../../../include/QtCore/qobjectdefs.h:1,
    8. from ../../../include/QtGui/../../src/gui/kernel/qwindowdefs.h:41,
    9. from ../../../include/QtGui/qwindowdefs.h:1,
    10. from ../../../include/QtGui/../../src/gui/kernel/qwidget.h:41,
    11. from ../../../include/QtGui/qwidget.h:1,
    12. from ../../../include/QtGui/../../src/gui/dialogs/qdialog.h:41,
    13. from ../../../include/QtGui/qdialog.h:1,
    14. from ../../../include/QtGui/../../src/gui/dialogs/qmessagebox.h:41,
    15. from ../../../include/QtGui/qmessagebox.h:1,
    16. from ../../../include/QtGui/QMessageBox:1,
    17. from DB_TRANS.cpp:2:
    18. C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/include/stddef.h:151: error: extraneous `int' ignored
    19. In file included from C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/char_traits.h:46,
    20. from C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/string:47,
    21. from ../../../include/QtCore/../../src/corelib/tools/qstring.h:56,
    22. from ../../../include/QtCore/qstring.h:1,
    23. from ../../../include/QtCore/../../src/corelib/kernel/qobject.h:44,
    24. from ../../../include/QtCore/qobject.h:1,
    25. from ../../../include/QtGui/../../src/gui/kernel/qwidget.h:42,
    26. from ../../../include/QtGui/qwidget.h:1,
    27. from ../../../include/QtGui/../../src/gui/dialogs/qdialog.h:41,
    28. from ../../../include/QtGui/qdialog.h:1,
    29. from ../../../include/QtGui/../../src/gui/dialogs/qmessagebox.h:41,
    30. from ../../../include/QtGui/qmessagebox.h:1,
    31. from ../../../include/QtGui/QMessageBox:1,
    32. from DB_TRANS.cpp:2:
    33. C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_algobase.h: In static member function `static _Tp* std::__copy_backward_dispatch<_Tp*, _Tp*, __true_type>::copy(const _Tp*, const _Tp*, _Tp*)':
    34. C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_algobase.h:407: error: no match for 'operator*' in 'sizeof (_Tp) * _Num'
    35. In file included from C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/string:48,
    36. from ../../../include/QtCore/../../src/corelib/tools/qstring.h:56,
    37. from ../../../include/QtCore/qstring.h:1,
    38. from ../../../include/QtCore/../../src/corelib/kernel/qobject.h:44,
    39. from ../../../include/QtCore/qobject.h:1,
    40. from ../../../include/QtGui/../../src/gui/kernel/qwidget.h:42,
    41. from ../../../include/QtGui/qwidget.h:1,
    42. from ../../../include/QtGui/../../src/gui/dialogs/qdialog.h:41,
    43. from ../../../include/QtGui/qdialog.h:1,
    44. from ../../../include/QtGui/../../src/gui/dialogs/qmessagebox.h:41,
    45. from ../../../include/QtGui/qmessagebox.h:1,
    46. from ../../../include/QtGui/QMessageBox:1,
    47.  
    48.  
    49. and many more errors like this
    To copy to clipboard, switch view to plain text mode 

    I m not able to diagnose the problem,

    Tell me the steps to connect to sQLite database

  2. #2
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: SQLITE include error

    Your class definition doesn't end with ';'.
    I'm a rebel in the S.D.G.

Similar Threads

  1. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 13:43
  2. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  3. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 02:49
  4. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19
  5. Qt-x11-commercial-src-4.2.0-snapshot-20060824 error
    By DevObject in forum Installation and Deployment
    Replies: 4
    Last Post: 24th August 2006, 23:31

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.