[Interest] Use QMetaEnum::keyCount() to initialise array

Konstantin Shegunov kshegunov at gmail.com
Wed Dec 19 10:37:23 CET 2018

On Wed, Dec 19, 2018 at 11:22 AM Tom Isaacson <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()];

const QMetaEnum metaEnum = QMetaEnum::fromType<Qt::Alignment>();

int MyArray[metaEnum.keyCount()];
Compiles for me (with g++ 8.2, -std=gnu++11 which is expanded from
CONFIG += c++11).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181219/1c206ca8/attachment.html>

More information about the Interest mailing list