I'm just starting out with Qt and I really want to try and keep my application as separated from Qt as possible in case I decide to use a different toolset later, but at the same time don't want to make any decisions that will really cripple my application right from the beginning.
When writing a Qt Application is it considered good practice to always prefer Qt implementations when they are available? Or in some situations is it best to stick with standard C++ even when Qt has an alternative?
Consider the following…
Function implementations:
Should I always prefer to use a Qt function implementation when it is availabe? Take the math functions for example…
pow
vsqPow
log
vsqLn
- etc…
Data types:
Should I always prefer Qt data types over the defaults?
int32_t
vsqint32
double
vsqreal
- etc…
Objects:
Should I always prefer Qt objects over their STL equivalents?
std::string
vsQString
std::vector
vsQVector
In each of these situations what are the advantages/disadvantages. What will I gain or lose?
The more Qt based functions/objects I use the more difficult it would be to switch to something other than Qt later.
Best Answer
If there is an exact equivalent in the C++ standard (like for exact-width types, or math functions), you loose portability to any project not using QT, without gaining anything. And people might wonder what that function / type / whatever does or does differently if they are not intimately knowledgeable about QT.
There are two reasons for using QT object types like
QString
andQVector
:Those two points apply in reverse to using the standard types instead.