[Qt-creator] Using Qt Enums as QML object keys... Qt6?

Jason H jhihn at gmx.com
Fri Mar 6 18:25:54 CET 2020

Sorry, all this should have gone to interest - please continue any discussion there.

/my bad

> Sent: Friday, March 06, 2020 at 12:23 PM
> From: "Jason H" <jhihn at gmx.com>
> To: qt-creator <qt-creator at qt-project.org>
> Subject: [Qt-creator] Using Qt Enums as QML object keys... Qt6?
> First, sometimes I find that not all Qt enums are exported to QML.
> Like the QProcess::ProcessState, IIRC. Are these bugs? Shouldn't all Qt enums in QObject recived classes be Q_ENUM()ed?
> Next, QML's uage of these is normally an int, when I print these with console.log() they come out as 0,1,2,3, etc. However, I was going to [ab]use this and tried
> var nameForState = {
>     QProcess.NotRunning: "QProcess::NotRunning",
>     QProcess.Starting: "QProcess::Starting",
>     QProcess.Running: "QProcess::Running",
> }
> But instead I have to provide an array:
> var nameForState = [ "QProcess::NotRunning","QProcess::Starting","QProcess::Running"]
> then index.
> console.log("process state", index, nameForState[state]);
> But this is a weaker binding and sometimes the table in the docs is not present, or if is present aren't ways in sorted order. Also QFlags are not possible to do this way.
> I am hoping for Qt6, we can console.log() without this additional lookup? Or at least use the object-based lookup and not the array version?
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> https://lists.qt-project.org/listinfo/qt-creator

More information about the Qt-creator mailing list