How to Use LibQxt with Qt Creator

What is LibQxt?

libqxtlogo

LibQxt [dev.libqxt.org] 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 [dev.libqxt.org]

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 [dev.libqxt.org] , select the Branches tab and download the master branch. Or you can just directly download here [dev.libqxt.org] (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:\Users\Bruce Outdoors\Documents\”) 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:\Qt”

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 [dev.libqxt.org] . 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:\Qt\libqxt-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:\Qt\Qt5.0.2\5.0.2\mingw47_32\bin) and mingw(C:\Qt\Qt5.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:\Qt\Qt5.1.0\5.1.0\mingw48_32\bin\;C:\Qt\Qt5.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:\Qt\libqxt-Qt5\lib) and the header files(C:\Qt\libqxt-Qt5\include).

Step 3: Header Files Fix

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

  1. D:\Libraries\Documents\GitHub\miniCsvProgram\miniCsvProgram.h:26: error: QxtCsvModel: No such file or directory

Why is that so? Well, that’s because the file QxtCsvModel (with no extensions) only has the line
  1. #include "qxtcsvmodel.h"

When the header file itself is not present! if you go now to Qt 5 directory in C:\Qt\Qt5.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:\Qt\libqxt-Qt5\src and open “core” there the header files for qxtcore are located. Arrange the files by type and copy paste all the header files(*.h) from C:\Qt\libqxt-Qt5\src\core to C:\Qt\libqxt-Qt5\include\QxtCore

Repeat the same process

C:\Qt\libqxt-Qt5\src\bdb > C:\Qt\libqxt-Qt5\include\Qxtbdb
C:\Qt\libqxt-Qt5\src\designer > C:\Qt\libqxt-Qt5\include\QxtCore
C:\Qt\libqxt-Qt5\src\network > C:\Qt\libqxt-Qt5\include\QxtNetwork
C:\Qt\libqxt-Qt5\src\sql > C:\Qt\libqxt-Qt5\include\QxtSql
C:\Qt\libqxt-Qt5\src\web > C:\Qt\libqxt-Qt5\include\QxtWeb
C:\Qt\libqxt-Qt5\src\widgets > C:\Qt\libqxt-Qt5\include\QxtWidgets
C:\Qt\libqxt-Qt5\src\zeroconf > C:\Qt\libqxt-Qt5\include\QxtZeroconf

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

  1. cd /path/to/libqxt/
  2. cp src/bdb/*.h include/Qxtbdb/
  3. cp src/designer/*.h include/QxtCore/
  4. cp src/network/*.h include/QxtNetwork/
  5. cp src/sql/*.h include/QxtSql/
  6. cp src/web/*.h include/QxtWeb/
  7. cp src/widgets/*.h include/QxtWidgets/
  8. cp src/zeroconf/*.h include/QxtZeroconf/

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://qt-project.org/wiki/Handling_CSV

minicsvprogram

And that’s it! Feedback and discussions please go to http://qt-project.org/forums/viewthread/27167/