[Development] Proposing changes to https://wiki.qt.io/Qt_Coding_Style

Marc Mutz marc.mutz at qt.io
Tue May 9 08:51:37 CEST 2023


Hi,

I'd like to propose the following clarifications:

- no space between "operator" and it's symbol:

     // WRONG
     bool operator ==(~~~~)
     // CORRECT
     bool operator==(~~~~)

Rationale: that's the style we find in all of Qt, but QtC's 
auto-completion (by default?) adds the space, so we should clarify what 
we want (and fix QtC).

- exactly one space each between if and constexpr/constinit and 
following [({]:

    // WRONG
    if  constinit(
        if     constexpr(~~~) {
    // CORRECT
    if constinit {
        if constexpr (~~~) {

- space after template and before <:

   // WRONG
   template<class T>
   // CORRECT:
   template <class T>

Rationale: We always used the latter in Qt. Then a faulty _clang-format 
that dropped the space for unknown reasons was added to qt5.git and 
since then, we have a wild mix. We should fix the faulty _clang-format 
file and codify just one variant in the normative document, 
https://wiki.qt.io/Qt_Coding_Style.

- drop the requirement for () in lambdas

Rationale: this was a word-around for older MSVCs. The standard doesn't 
require the empty parameter list (except when adorning the lambda with 
noexcept etc, and then the compiler complains) and people have voted 
with their feet: we now have many uses of [] {} in Qt already.

Thanks,
Marc

-- 
Marc Mutz <marc.mutz at qt.io>
Principal Software Engineer

The Qt Company
Erich-Thilo-Str. 10 12489
Berlin, Germany
www.qt.io

Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen
Sitz der Gesellschaft: Berlin,
Registergericht: Amtsgericht Charlottenburg,
HRB 144331 B


More information about the Development mailing list