Hi, Il 26/03/26 07:13, Sze Howe Koh ha scritto:
Does the Qt Project have a preference between the following?QVector2D myVector = QVector2D(x, y); vs. QVector2D myVector(x, y); Context: https://codereview.qt-project.org/c/qt/qtdeclarative/+/642149 used the former; https://codereview.qt-project.org/c/qt/qtdeclarative/+/724447 copies the older patch's logic while trying the latter syntax. I plan to make them consistent with each other, but I don't know which way is preferred. https://wiki.qt.io/Qt_Coding_Style and https://wiki.qt.io/Coding_Conventions don't discuss this.
No, it's up to the author's preferences, hopefully by mimicking the surrounding style. There's a minor preference towards using copy initialization in general and/or braced initialization (in order to avoid the most vexing parse), but again it's up to you. To be honest I don't think anyone would write `QVector2D myvector = {x, y}` (I certainly wouldn't).
Do note that the two forms you posted above are absolutely equivalent, and in neither case there's copy initialization.
[insert meme on how many different syntaxes C++ has for initialization and how each one is subtly broken]
Thank you, -- Giuseppe D'Angelo | [email protected] | Senior Software Engineer KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com KDAB - Trusted Software Excellence
smime.p7s
Description: Firma crittografica S/MIME
-- Development mailing list [email protected] https://lists.qt-project.org/listinfo/development
