LibQxt in QtCreator

From Qt Wiki
Revision as of 14:38, 23 February 2015 by Maintenance script (talk | contribs)
Jump to navigation Jump to search

h1. How to Use LibQxt with Qt Creator

What is LibQxt?

libqxtlogo

"LibQxt":http://dev.libqxt.org/libqxt/wiki/Home is an extension library for Qt providing a suite of cross-platform utility classes to add functionality not readily available in the Qt toolkit by Qt Development Frameworks, Digia.

You can find the documentation at http://doc.libqxt.org/

For this guide I'm using windows 7 32bit, Qt 5.0.2 with MinGW, but it should be fairly straight forward for other platforms as well.

Step 1: Download

If you want to compile for Qt 4, the current version would suffice(as of this writing - 26/4/2013 - the most recent stable version of libqxt is v6.0.7). You can download it from "here":http://dev.libqxt.org/libqxt/wiki/Home

If you are using Qt 5, you'll need to download from the latest branch as the commit for Qt 5 compatibility only came in Febuary 2013. Go to "this link ":http://dev.libqxt.org/libqxt/downloads , select the Branches tab and download the master branch. Or you can just "directly download here":http://dev.libqxt.org/libqxt/get/master.zip (http://dev.libqxt.org/libqxt/get/master.zip )

Step 2: Build

Extract the contents of your file to your hard disk. Make sure the directory doesn't have any spaces(e.g "C:Outdoors\Documentsquot;) otherwise it will fail and you probably won't be able to figure our why. For this guide I extract the folder "libqxt-libqxt-7c83e1694ed5" to "C:"

I will also rename "libqxt-libqxt-7c83e1694ed5" to "libqxt-Qt5" because I can't remember a bunch of random numbers and letters.

"Original instructions are here":http://dev.libqxt.org/libqxt/overview . So… you can't just open the pro file in Qt Creator just yet. In windows you will run "configure.bat" in your libqxt directory(in this case it will be located in C:-libqxt-Qt5).

  1. deselect everything and Shift+Right Click on an empty space in the libqxt directory and select "Open command window here".
  2. type configure.bat and press enter
  3. type mingw32-make

If the above steps doesn't work, or if you get an error such as You don't seem to have 'qmake' in your PATH, either make sure you have Qt 5 bin(C:5.0.2\5.0.2\mingw47_32\bin) and mingw(C:5.0.2\Tools\MinGW\bin) folder in your environment paths or that you don't have both Qt 4 and Qt 5 in your environment paths. Mine looks like this: C:5.1.0\5.1.0\mingw48_32\binC:5.1.0\Tools\mingw48_32\bin

building-libqxt

Now wait for about 10-15 minutes. After that you will find the library files in the lib folder in the libqxt directory(in our case C:-Qt5\lib) and the header files(C:-Qt5\include).

Step 3: Header Files Fix

If you were to use the library now(for example #include <QxtCsvModel&gt;), even after you add your dependancy path(C:-Qt5\include\QxtCore) you will come with with errors like

<br />D:.h:26: error: QxtCsvModel: No such file or directory<br />


Why is that so? Well, that's because the file QxtCsvModel (with no extensions) only has the line

<br />#include &quot;qxtcsvmodel.h&amp;quot;<br />


When the header file itself is not present! if you go now to Qt 5 directory in C:5.0.2\5.0.2\mingw47_32\include\QtCore there are both blank files and header files side by side. To fix this for libqxt, navigate to the source folder in C:-Qt5\src and open "core&quot; there the header files for qxtcore are located. Arrange the files by type and copy paste all the header files(.h) from C:-Qt5\src\core to C:-Qt5\include\QxtCore


Repeat the same process
C:-Qt5\src\bdb>* C:-Qt5\include\Qxtbdb
C:-Qt5\src\designer
> C:-Qt5\include\QxtCore
C:-Qt5\src\network
> C:-Qt5\include\QxtNetwork
C:-Qt5\src\sql
> C:-Qt5\include\QxtSql
C:-Qt5\src\web
> C:-Qt5\include\QxtWeb
C:-Qt5\src\widgets
> C:-Qt5\include\QxtWidgets
C:-Qt5\src\zeroconf
> C:-Qt5\include\QxtZeroconf

Execute the below commands if you have cygwin or bash to do this quickly

<br />cd /path/to/libqxt/<br />cp src/bdb/*.h include/Qxtbdb/<br />cp src/designer/*.h include/QxtCore/<br />cp src/network/*.h include/QxtNetwork/<br />cp src/sql/*.h include/QxtSql/<br />cp src/web/*.h include/QxtWeb/<br />cp src/widgets/*.h include/QxtWidgets/<br />cp src/zeroconf/*.h include/QxtZeroconf/<br />

I'm not sure if there are other ways… if you know post in my forum post or simply edit this wiki.

Step 4: Using LibQxt in Your Qt Creator Projects

The best way to learn is by example. Here is a CSV reader and writer made with Qt 5 and the QxtCsvModel:

http://wiki.qt.io/Handling_CSV

minicsvprogram