PDA

View Full Version : QtSDK : how to connect Qt Creator to MySQL (QMySQL Driver)



wiralim
6th April 2012, 10:07
This tutorial is just for the SDK user for connecting the Qt Creator to the Database (MySQL).

Just follow this link : http://ieatbinary.com/2011/07/11/how-to-enable-mysql-support-in-qt-sdk-for-windows/
it will be useful.

Things to watch out before proceeding the steps (on above link):

1. Make sure to install MySQL Server 5.x 32 bit (not 64 bit), and install it on C:\MySQL not C:\MySQL\Program Files (x86)\bla bla bla.
because it will be easier when u proceed step 4 (on that link).
if u have installed it on C:\MySQL\Program Files (x86)\bla bla bla, then u have to use dir /x on ur Qt Command Prompt (Qt 4.8.0 for Desktop (MingW))
to search the short path name of the directory containing space, likes : C:\Program Files (x86)\MySQL\MySQLServer55\bin ---> it will be :
C:\PROGRA~2\MySQL\MySQLServer55\bin

2. Rename the My SQL Server 5.5 ----> MySQLServer55 (not containing space)

3. On step 4. Run these commands (change according to your environment):
i didn't do the 1st and 2nd step : > set mysql=C:\PROGRA~2\MySQL\MYSQLS~1.5
> cd \
i just skip to 3rd step : > cd QtSDK\QtSources\4.7.3\src\plugins\sqldrivers\mysql \

4. still on step 4, if u have found this error WARNING: (internal):1: Unescaped backslashes are deprecated when executing the qmake "INCLUDEPATH+=blablabla.... , then u have to change one backslashes(\) become two backslashes (\\) on every qmake execution, eg :

qmake "INCLUDEPATH+=C:\PROGRA~2\MySQL\MySQLServer55\inclu de" "LIBS+=C:\PROGRA~2\MySQL\MySQLServer55\lib\libmysql .lib" -o Makefile mysql.pro
become
qmake "INCLUDEPATH+=C:\\PROGRA~2\\MySQL\\MySQLServer55\\i nclude" "LIBS+=C:\\PROGRA~2\\MySQL\\MySQLServer55\\lib\libm ysql.lib" -o Makefile mysql.pro

it Works...

Sorry if my english is poor, because i'm not the native

wiralim
7th April 2012, 06:05
Sry guys, after u have done all the steps and sucessfully adding the QMYSQL DRIVER in Qt, then u should change back the MySQLServer55 directory name to the original name (back to when u installed MySQL Server). It should be like this : MySQL Server 5.5