[Interest] Use QMetaEnum::keyCount() to initialise array
Nikos Chantziaras
realnc at gmail.com
Wed Dec 19 18:22:17 CET 2018
On 19/12/2018 11:37, Konstantin Shegunov wrote:
> On Wed, Dec 19, 2018 at 11:22 AM Tom Isaacson <Tom.Isaacson at navico.com
> <mailto:Tom.Isaacson at navico.com>> wrote:
>
> Is it possible to use QMetaEnum::keyCount() to initialise an array?
> Something like:
>
> const QMetaEnum metaEnum = QMetaEnum::fromType<MyArray>();
> int MyArray[metaEnum.keyCount()];
>
> constQMetaEnummetaEnum=QMetaEnum::fromType<Qt::Alignment>();
>
> intMyArray[metaEnum.keyCount()];
>
> Compiles for me (with g++ 8.2,-std=gnu++11 which is expanded from CONFIG+=c++11).
Unfortunately, that's a variable length array, which is a GNU extension.
More information about the Interest
mailing list