This is probably hijacking your post, but I've always found it bad style to have different conventions for C++ and QML.
//C++ convention int Class::memberF() { } //QM convention:, compressed is used: Rectangle { onVisibleChanged: { .... } } I'd like to get everything down to one style (preferable QML's) As to your question, using a lot of modern C++ initializers, I've found myself using braces with spaces when using lists, and just preferring more whitespace in general. When using (), I don't post space, so new Item("name", parent); stays. However your example of new Item { "name", parent }; really bothers me. If you're calling a function, keep that with () and only use { } for the other things. I do not know how far back the compilers would allow new Item { "name", parent }; but it just doesn't look right to me. I understand there may be a push to make it modern, but not everyone should need to be at the level of proficiency of modern to feel comfortable in Qt. So I encourage the principal of oldest possible expressible syntax. If Qt started using new Item { "name", parent };, I would freak. Thiago has criticised some of my suggestions for source compatibility, and he's right to do so. But I'm arguing for backwards mental source compatibility. When reading new code I often wonder "Is this a new concept or and old one new to me?" And if it's a new concept, what's the minimum C++0x version that I need? The only thing beyond better initializer lists that I really find that I like about modern C++ is that you can use structured bindings to decompose a pair into better-named variables than 'pair.first' and 'pair.second'; Unfortunately, structured bindings are not supported by the Android NDK yet* (*the last time I checked). > Sent: Friday, December 21, 2018 at 1:59 AM > From: "Alberto Mardegan" <ma...@users.sourceforge.net> > To: development@qt-project.org > Subject: [Development] Braces (was Re: Resolving coding style contentions) > > Hi all! > Speaking of coding style again, I haven't found any indication in the > coding guidelines about brace vs parentheses in initializations. > > There are a few cases where they can be used (and I might even be > forgetting some): > > 1) Constructors: > MyClass(): var(0) {} > vs > MyClass(): var { 0 } {} > > 2) Member initializations: > class MyClass > { > int m_count = 3; > vs > int m_count { 3 }; > > 3) Variable initialization > bool ok = false; > vs > bool ok { false }; > > 4) Constructor invocations: > auto *item = new Item("name", parent); > vs > auto *item = new Item { "name", parent }; > > or > > QString message(QStringLiteral("text")); > vs > QString message { QStringLiteral("text") }; > I guess this is not an option: > QString message { QStringLiteral { "text" } }; > > > I'm not mentioning the cases of struct and list initializers, where of > course braces are the only option. But what is the consensus on the > cases above? > Looking at the Qt code, it seems that variant without braces is always > preferred, but I cannot find it formalized anywhere. > > Ciao, > Alberto > > -- > http://blog.mardy.it - Geek in un lingua international > _______________________________________________ > Development mailing list > Development@qt-project.org > https://lists.qt-project.org/listinfo/development > _______________________________________________ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development