Re: [Development] std::optional for Q_PROPERTY

2023-11-27 Thread Ulf Hermann via Development
How about conversion: QVariant(std::optional>).value(); // return U{} if T cannot be converted; otherwise U(T); QVariant().value>(); // nullopt, not a std::optional holding a T{} QVariant(42).value>(); // std::optional holding 42 QVariant(QSize()).value>(); // probably

Re: [Development] std::optional for Q_PROPERTY

2023-09-25 Thread Pierre-Yves Siret
Digging up this conversation cause I believe it would be a big added value, or at least make it should be made clear if that's not possible. Le ven. 21 juil. 2023 à 11:37, Giuseppe D'Angelo via Development < development@qt-project.org> a écrit : > On 21/07/2023 11:01, Volker Hilsheimer via

Re: [Development] std::optional for Q_PROPERTY

2023-07-21 Thread Giuseppe D'Angelo via Development
On 21/07/2023 11:01, Volker Hilsheimer via Development wrote: How about conversion: I, for one, would like to stop seeing magic conversions added into QVariant, and keep breaking stuff at every Qt major release because we realize we went overboard and have to remove features. Now, one

Re: [Development] std::optional for Q_PROPERTY

2023-07-21 Thread Volker Hilsheimer via Development
> On 20 Jul 2023, at 16:17, Fabian Kosmale via Development > wrote: >> Hi everyone, >> >> something that came up during this year’s KDE Akademy was that we >> believe Q_PROPERTY should be able to handle std::optional, such that you >> get a null QVariant out of it if it has no value. The main

Re: [Development] std::optional for Q_PROPERTY

2023-07-20 Thread Kai Uwe Broulik
Hi, > That would mostly work, unless you want > a RESETable property, where RESET shouldn't lead to a nullopt value. It’s perfectly valid to have RESET set the value to whatever it thinks is correct, isn’t it? All it means is I can assign `undefined` from QML and have _something_ come out of

Re: [Development] std::optional for Q_PROPERTY

2023-07-20 Thread Fabian Kosmale via Development
is worthwhile, but I'm currently not sure what the best way forward would be. Kind regards, Fabian Von: Development im Auftrag von Kai Uwe Broulik Gesendet: Donnerstag, 20. Juli 2023 15:41 An: development@qt-project.org Betreff: [Development] std::opti

Re: [Development] std::optional for Q_PROPERTY

2023-07-20 Thread Pierre-Yves Siret
Le jeu. 20 juil. 2023 à 15:41, Kai Uwe Broulik a écrit : > Hi everyone, > > something that came up during this year’s KDE Akademy was that we > believe Q_PROPERTY should be able to handle std::optional, such that you > get a null QVariant out of it if it has no value. The main use case > being

Re: [Development] std::optional for Q_PROPERTY

2023-07-20 Thread Elias Steurer via Development
Hi, I would like to voice my support for this and even extend the idea: * std::expected would also be nice here, because it can tell you /what/ went wrong. Yes, I know it is C++23... * Support for smart pointers, see QTBUG-60136 . It is

[Development] std::optional for Q_PROPERTY

2023-07-20 Thread Kai Uwe Broulik
Hi everyone, something that came up during this year’s KDE Akademy was that we believe Q_PROPERTY should be able to handle std::optional, such that you get a null QVariant out of it if it has no value. The main use case being interfacing “more modern C++” with QML in a type-safe way, rather