go-qml / qml

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

[]string as model for ComboBox #123

Open averrin opened 9 years ago

averrin commented 9 years ago

In QML:

ComboBox { model: profiles }

where profiles := []string{"one", "two"}

and in console output: panic: handling of []string (&[]string{"one", "two"}) is incomplete; please report to the developers

Is there workaround, or ComboBox is broken?

averrin commented 9 years ago

My next idea:

model := new(qml.List)
model.Convert(&options.Profiles)
context.SetVar("ProfilesModel", model)

But, it have no effect: ComboBox.qml:503: file:///usr/lib/x86_64-linux-gnu/qt5/qml/QtQuick/Controls/ComboBox.qml:503:23: Unable to assign List to QString

John-Gee commented 9 years ago

I've been hitting the same issue tonight, so I'm very interested in this. Have you found a workaround?

averrin commented 9 years ago

Yeah, but with big hack. I think, go-qml still not usefull. Workaround: https://github.com/averrin/openmw_launcher/blob/4fbd384879d3067c06c7f6f747d8c6f57079fa6c/src/main.qml https://github.com/averrin/openmw_launcher/blob/4fbd384879d3067c06c7f6f747d8c6f57079fa6c/src/launcher.go But this solution have a strange random bugs.

John-Gee commented 9 years ago

I've quickly looked over it, and it seems a great idea. I will try it a bit later and see how it works for me, thank you for sharing it!

John-Gee commented 9 years ago

It worked! You saved me!

nikwen commented 9 years ago

I created a more general bug report regarding []string crashes here: https://github.com/go-qml/qml/issues/132 It also contains a reference to the delegate example, which is (in my opinion) a better workaround for this model issue.