Issue with using *QFileDialog.SelectedFiles(), "interface conversion: interface {} is []interface {}, not []string"
arturfabriciohahaedgy opened this issue · 1 comments
arturfabriciohahaedgy commented
The Issue
I'm trying to get the directories selected when using QFileDialog but I keep getting the following error:
panic: interface conversion: interface {} is []interface {}, not []string
goroutine 20 [running]:
github.com/therecipe/qt/widgets.(*QFileDialog).SelectedFiles(0x0?)
C:/Users/_/go/pkg/mod/github.com/therecipe/qt@v0.0.0-20200904063919-c0c124a5770d/widgets/widgets.go:13192 +0x15e
main.main.func1(0x0)
D:/junk/qt-test/window.go:52 +0x70
reflect.Value.call({0x1967000?, 0xc000008828?, 0x1ee2040?}, {0x1bcaf82, 0x4}, {0xc0002104b0, 0x1, 0xd514a5?})
C:/Program Files/Go/src/reflect/value.go:584 +0x8c5
reflect.Value.Call({0x1967000?, 0xc000008828?, 0xc000200330?}, {0xc0002104b0?, 0x1953d40?, 0x0?})
C:/Program Files/Go/src/reflect/value.go:368 +0xbc
github.com/therecipe/qt/internal.handleCallback({0xc000116606, 0x22})
C:/Users/_/go/pkg/mod/github.com/therecipe/qt@v0.0.0-20200904063919-c0c124a5770d/internal/internal.go:73 +0x2fd
github.com/therecipe/qt/internal.asyncCallbackHandler({0xc000116606?, 0x0?})
C:/Users/_/go/pkg/mod/github.com/therecipe/qt@v0.0.0-20200904063919-c0c124a5770d/internal/internal.go:109 +0x1e
created by github.com/therecipe/qt/internal.InitProcess.func3
C:/Users/_a/go/pkg/mod/github.com/therecipe/qt@v0.0.0-20200904063919-c0c124a5770d/internal/internal.go:407 +0xf5
I don't even know if this library is recieving maintenance anymore, but if it is I'd like to know if it's an issue with my code or the library itself
The code
widget := widgets.NewQWidget(nil, 0)
widget.SetLayout(widgets.NewQHBoxLayout())
mw.MainWin.SetCentralWidget(widget)
input := widgets.NewQLineEdit(nil)
input.SetPlaceholderText("Insert path...")
widget.Layout().AddWidget(input)
fileDialog := widgets.NewQFileDialog2(nil, "Select file", ".", "")
fileDialog.SetFileMode(widgets.QFileDialog__Directory)
button := widgets.NewQPushButton2("Search folders", nil)
button.SetMaximumSize2(50, 50)
button.ConnectClicked(func(bool) {
widgets.QMessageBox_Information(nil, "OK", input.Text(), widgets.QMessageBox__Ok, widgets.QMessageBox__Ok)
if fileDialog.Exec() == 1 {
files := fileDialog.SelectedFiles()
fmt.Printf("V: %v", files)
}
})
widget.Layout().AddWidget(button)
The error always happens at when .SelectedFiles() is called.
NaymDev commented
I have a similair error calling .Urls()