QT uses the problem of SQLite, a lot of pits

Source: Internet
Author: User
Tags sqlite sqlite database

1. I use SQLite, the development of a good machine, the test machine is not. Later found to be missing driver (Driver not loaded Driver not loaded), code check and check, found should be missing DLL file (System does not prompt, is itself using qmessagebox::warning (NULL, ("error") , Database.lasterror (). text ()); after guessing). So I try to find a way, repeated testing, is not. As a result of the tragic discovery, the original is to set the path error many times, waste a morning time. directories and files should be set directly in the same directory as the executable EXE file:
My.exe\sqldrivers\qsqlite4.dll
Do not write either:
My.exe\plugins\sqldrivers\qsqlite4.dll
Don't write it.
My.exe\sqldrivers\sqlite\qsqlite4.dll (because Qt's own directory is C:\Qt\4.8.6_2008\src\plugins\sqldrivers\sqlite)
In addition, it is useless to put it in the same directory as My.exe.

2. When programming, note that you cannot use new Qsqldatabase () and then call the Adddatabase () function. The reason is what I don't know, anyway conclusion here:
Http://qt-project.org/doc/qt-4.8/qsqldatabase.html#open

3. When programming, be careful to fill in qsqlite, not SQLite
Qsqldatabase database = Qsqldatabase::adddatabase ("Qsqlite");

4. When using the Qsqldatabase::adddatabase function, if it is a temporary object, then name it, for example (the key is the second parameter):
Qsqldatabase LocalDB = qsqldatabase::adddatabase ("Qsqlite", "old_db");
If you do not write this second argument, then the new connection will be treated as a default connection, so the application of the Qsqlquery object without stating the database connection will be an error.

5. When using Qsqldatabase::removedatabase, it is necessary to enclose all of the preceding statements in parentheses, a baffling use. But since it's official documentation, just remember it, follow it, and the links are here:
Http://qt-project.org/doc/qt-4.8/qsqldatabase.html#removeDatabase

6. There is also a file Qsqlited4.dll, do not know what to do.

7. It is easy to use vs compile C:\Qt\4.8.6_2008\src\plugins\sqldrivers\ SQLite path under the Sqlite.pro project file, release compiled to get a DLL, put in the relevant path to use no problem.

8. Process Explorer This software can clearly show that the current development of the EXE file depends on which DLLs, it is helpful. So you don't have to use your brains to see the results. For example, I am dependent on this project:

C:\Qt\4.8.6_2008\plugins\sqldrivers\qsqlite4.dll
Note, however, that it prompts for the DLL path on the development machine, and the path on the client is not necessarily the case.

But its hints can only be used as a reference, not completely taken seriously, it also prompts me to use:
C:\Qt\4.8.6_2008\plugins\imageformats\qtiff4.dll
But I didn't use TIFF files at all. So this tip as a reference, find the information you need.

Summary, QT release version of the Pit is so many, no wonder QT company do not let free users static compilation and modification, probably only let the experts to play with it. It is not known whether static compilation can avoid these problems.

---------------------------------------------------------------------------

Several useful connections:
Http://qt-project.org/doc/qt-4.8/sql-driver.html
Http://blog.sina.com.cn/s/blog_a6fb6cc90101gx30.html
http://blog.csdn.net/hustyangju/article/details/17799189
Http://blog.chinaunix.net/uid-28394603-id-3775493.html (Discussion rollback)

To install the MySQL driver:
Http://blog.sina.com.cn/s/blog_74a7e56e01017s64.html

Plugin working mechanism:
http://blog.csdn.net/dbzhang800/article/details/6543489
http://blog.csdn.net/csfreebird/article/details/17793161

SQLite Learning Handbook
http://my.oschina.net/eechen/blog/84641
http://my.oschina.net/eechen/blog/84639
http://www.oschina.net/question/12_53183 (Learn SQLite database within one hours)

QT uses the problem of SQLite, a lot of pits

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.