[Interest] QML Values to enum name

Jason H jhihn at gmx.com
Tue Sep 20 21:34:11 CEST 2016


Without having to create my own mapping object, I'd like to get the name from values:

WebSocket {
	id: webSocket
	onStatusChanged: console.log("webSocket status:", status) // prints 3 or 4
}

I'd like to be able to do:
  onStatusChanged: console.log("secWebSocket status:", WebSocket.Status(status)) // prints "Open" or "Closed"

or something like that...
 WebSocket.enum(Status).value(status)), WebSocket.enumValue(Status, status), WebSocket.Enums.Status.value(4). I don't really care, I just want to have to explore the mapping myself. I say explore, because the docs say:


status : Status

Status of the WebSocket.
The status can have the following values:
WebSockets.Connecting
WebSockets.Open
WebSockets.Closing
WebSockets.Closed
WebSockets.Error


So then I have to go through and go through a trivial mapping exercise to find out what the constants are. 


Is there a better way to do this?



More information about the Interest mailing list