[Interest] Proper way of testing whether Qt is being used by a program

Shriramana Sharma samjnaa at gmail.com
Tue Aug 14 12:57:56 CEST 2012

Hello I'm new to this list. I'm an academic of the humanities and use
Qt now and then via C++ / Python+PyQt in relation with my academic
projects. I should not I'm *not* a highly experienced advanced
programmer, but am OK with intermediate stuff.

I have a small library which I would like to be used with both Qt and
non-Qt programs. Basically I want to use QList if the calling program
will be using Qt anyway, else I want to use std::deque (which seems to
be the one with most similar API to QList). So I am thinking of using
#define-s like:

#define MyList QList
#include <deque>
#define MyList std::deque

... and then use MyList throughout my code. I assumed that it is safe
to assume that if QT_VERSION is defined, Qt is being used? Is this OK?
I want to know what is the accepted/conventional of testing whether Qt
is being used.

In relation, if a program uses Qt, does it mean it also uses the STL
containers anyway? I'm asking since QList seems to have facilities to
convert to and from some STL containers which may not be possible if
they are not used somewhere inside Qt?

(Note: I am aware that the API of QList is not identical to that of
the STL containers -- obviously I'd be using only the identical


Shriramana Sharma

More information about the Interest mailing list