[Qt-creator] Proposals for Updating the Qt Creator Coding Style
daniel.teske at digia.com
Wed Oct 1 16:21:45 CEST 2014
since current master allows for using qt5 only features in Creator's source
code, I propose the following (independent) changes/additions to our coding
** Qt5 connects vs Qt4 connects
- Prefer to use qt5 style connects with member function pointers to the qt4
style of using SIGNAL and SLOT macros.
- Avoid overloading signals or slots
- Avoid calling connect via "object->connect()"
- Be careful with lambda slots
The qt5 connects are type checked at compile time, which eliminates a huge
error source. Also the code model can understand them better than the SIGNAL
and SLOT macros.
** Qt Logging Framework
- This is the preferred solution for logging in Creator.
Reasons: This allows for one way to disable/enable logging for all of Creator.
- Prefer to use QRegularExpression to QRegExp, except if you need QRegExp's
features, e.g. wildcard matching.
- If the code is performance critical measure which regular expression engine
QRegularExpression has a better api and a more commonly used pattern syntax.
In general performance should be better, but if it matters, you need to
- Prefer to use instead of QString::fromLatin1()
- QLatin1String is still fine to use, if you don't need a QString
There's no huge difference to using QStringLiteral or not.
More information about the Qt-creator