[Qt-creator] Proposals for Updating the Qt Creator Coding Style

André Pönitz apoenitz at t-online.de
Wed Oct 1 20:56:28 CEST 2014


On Wed, Oct 01, 2014 at 04:21:45PM +0200, Daniel Teske wrote:
> Hi,
> 
> since current master allows for using qt5 only features in Creator's source 
> code, I propose the following (independent) changes/additions to our coding 
> style.
> 
> ** 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
> 
> Reasons:
>  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.

That's ok. Benefits like compile-time checks all over the place.

> ** 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.

Please use it with care, in situations where having the information or
not makes an actual difference. The logging code remains in the final
executable.
 
> ** QRegularExpression
> - 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
>   is faster.
> 
> Reasons:
> 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 
> measure.
> 
> ** QStringLiteral
> - Prefer to use instead of QString::fromLatin1()
> - QLatin1String is still fine to use, if you don't need a QString
> 
> Reasons:
> There's no huge difference to using QStringLiteral or not.

Ok.

Andre'



More information about the Qt-creator mailing list