go-qml / qml

QML support for the Go language
Other
1.96k stars 187 forks source link

Cannot pass []string to QML #132

Open nikwen opened 9 years ago

nikwen commented 9 years ago

When trying to pass a []string to QML, I always get the following error:

panic: handling of []string (&[]string{"element 1", "element 2", "element 3"}) is incomplete; please report to the developers

A workaround for this is using a wrapping struct like the Colors struct in the delegate example. Then everything works fine.

It doesn't matter whether I try to pass the []string as the return value of a method or using context.SetVar(). The application always crashes.

jhawk28 commented 9 years ago

This would be really helpful and make the use of goqml more straightforward.

mpiannucci commented 9 years ago

This crash happens when passing a string to QML as well.

panic: handling of string ((*string)(0xc20800a390)) is incomplete; please report to the developers
maja42 commented 8 years ago

Is there a workaround for this issue? I'm unable to get a list of strings/structs/ints,... into the qml land, without using context.Call() and passing one element after another, while the qml site reconstructs the original array

jhawk28 commented 8 years ago

The workaround is to create a size variable that is accessible to the QML side. You then need to create a get function on the Go side. The QML can then use a loop and iterate over all the elements and pull them in.

Basically, reconstruct the array on the QML side.

lordwelch commented 8 years ago

You could also just join the []string into a single string and then separate it in qml