Enabling FTS (module) in SQLITE for QT
If you want to use SQLITE extensions such as Full Text Search (FTS3 or FTS4) you might find out that Trolltech/Nokie doesn’t deliver the DLL with FTS support by default (at least in windows). So what you have to do in order to enable an extension is tell SQLITE to embed it during compilation. Follow [...]
Run an Application Only Once
Use the following code in the main.cpp to prevent to run more than one instance of your application. I tested this code under Linux (in QtCreator) and it works (works for Windows too). I find this solution simple and easy to implement. The example is for a console application. The code remain the same for [...]
entry point cannot be found
If you are getting the following error, you might have copied the wrong dlls: “The procedure entry point _Z17qt_message_output9QtMsgTypePKc could not be located in the dynamic link library QtCore4.dll” Use the dlls (QtCore4.dll, QtGui4.dll…) that are inside: C:\Qt\2010.05\qt\bin not the ones that are in C:\Qt\2010.05\bin
replacing special characters
Here is a little example of how to replace special characters with codepoint bigger than 255. Let’s assume that we want to replace the french character Œ or œ (a ligature of o and e) with oe.
How to serialize data using Qt
Qt provides two classes for serialization, DataStream class to serialization of binary data and QTextStream to “parsing” input stream(reading and writing text). QDataStream class can be used to write portables files (i.e., a data stream written under Windows can be read by other running GNU/Linux or Solaris). The example below shows how to Serialize and [...]
Foreach line in a QByteArray
1 2 3 4 QList<QByteArray> lines = data.split(’\n’); foreach ( const QByteArray &line, lines ) { qDebug()<<line; }
Make Your Qt App Look Native
Qt uses native style APIs on each supported platform, however there are some additional tricks you can use to make sure your Qt-based application looks, feels and behaves better. This presentation will run through examples, tips and ticks to help you make your applications look great on all platforms.
How do I find the widget that is at a given (X,Y) position?
Here’s a little example of how to determine the widget that is at a given position (Hit test). In the following example the widget at the current mouse position is determined.
Filtering relational tables in QSqlRelationalTableModel
As you know the QSqlRelationalTableModel class provides an editable data model for a single database table, with foreign key support. model->setTable("employee"); model->setRelation(2, QSqlRelation("city", "id", "name")); model->setRelation(3, QSqlRelation("country", "id", "name")); In this example the setRelation() function calls establish a relationship between two tables. The first call specifies that column 2 in table employee is a foreign [...]