Namespace vs. Prefix - recommended naming practice for Qt libraries
Normally If I develop a certain C++ library I put my data and classes into C++ namespaces. In the Qt library and certain Qt related libraries like Qxt or Qwt no namespaces are used but all data and classes qre prefixed (Qt library – Q, Qxt library – Qxt, Qwt library – Qwt). So I would like to know if there is a recommended practice for naming when developing a library that uses Qt classes and provides classes derived from Qt.
We have a Qt vision library here and I’m not sure whether to put all the library stuff into Qvi namespace or to go the Qt way and prefix all classes and data with Qvi prefix and ignore namespaces. A third solution would be to mix both – that means put all data prefixed with Qvi into Qvi namespace.
What would a Qt developer recommend here? Was there a certain reason for not using namespaces for Qt (i.e. maybe old C++ compilers did not support namespace properly)?
3 replies
I certainly recommend to use namespaces!
The Prefixing is from my understanding mostly a relict from the dark ages when compilers did not yet support those properly. Once done it is hard to change from prefixes to namespaces, but even Qt can be configured to use namespaces nowadays and we most certainly use them e.g. in Qt Creator.
You must log in to post a reply. Not a member yet? Register here!



