therecipe / qt

Qt binding for Go (Golang) with support for Windows / macOS / Linux / FreeBSD / Android / iOS / Sailfish OS / Raspberry Pi / AsteroidOS / Ubuntu Touch / JavaScript / WebAssembly
GNU Lesser General Public License v3.0
10.47k stars 747 forks source link

panic: interface conversion: interface {} is []*widgets.QAction, not []interface {} #1204

Open njfanxun opened 3 years ago

njfanxun commented 3 years ago

when i use qtDesigner create toolbar and actions in .ui file. qtDeploy desktop and generate uic_xxxx.go file , run build in goland occur a panic. the error in generate go file is ToolBar.AddActions([]*widgets.QAction{...})

panic: interface conversion: interface {} is []*widgets.QAction, not []interface {}
goroutine 1 [running, locked to thread]:
github.com/therecipe/qt/internal.convertToJson(0x1dfea20, 0xc00000eae0, 0x1e315a0, 0x2408ba0)
        /Users/fanxun/Project/go/src/etcd-dragon/vendor/github.com/therecipe/qt/internal/internal.go:176 +0x8ef
github.com/therecipe/qt/internal.convertListToJson(0xc0000782d0, 0x5, 0x5, 0x0, 0x8, 0x18)
        /Users/fanxun/Project/go/src/etcd-dragon/vendor/github.com/therecipe/qt/internal/internal.go:149 +0x62
github.com/therecipe/qt/internal.convertToJson(0x1e00ba0, 0xc00000eb00, 0x5, 0xc00000eb00)
        /Users/fanxun/Project/go/src/etcd-dragon/vendor/github.com/therecipe/qt/internal/internal.go:176 +0x69c
github.com/therecipe/qt/internal.CallLocalFunction(0xc0000782d0, 0x5, 0x5, 0xc00000eae0, 0x100e718)
        /Users/fanxun/Project/go/src/etcd-dragon/vendor/github.com/therecipe/qt/internal/internal.go:217 +0x66
github.com/therecipe/qt/widgets.(*QWidget).AddActions(0xc00009bb30, 0xc000010130, 0x1, 0x1)
        /Users/fanxun/Project/go/src/etcd-dragon/vendor/github.com/therecipe/qt/widgets/widgets.go:58433 +0x164
etcd-dragon/ui.(*MainWindow).setupUI(0xc00020a5a0)
        /Users/fanxun/Project/go/src/etcd-dragon/ui/uic_main_window.go:53 +0x5fb
etcd-dragon/ui.NewMainWindow(0x0, 0x0, 0xbd0a310)
        /Users/fanxun/Project/go/src/etcd-dragon/ui/uic_main_window.go:28 +0x155
etcd-dragon/controller.NewMainWindow(0xc00009c240, 0xc00009c240)
        /Users/fanxun/Project/go/src/etcd-dragon/controller/main_window.go:10 +0x2d
main.main()
        /Users/fanxun/Project/go/src/etcd-dragon/main.go:25 +0xfb

go version 1.14.7 qt version 5.13.0

reformc commented 3 years ago

I have the same question.

reformc commented 3 years ago

I solved you should not use go run or go build download https://github.com/therecipe/env_windows_amd64_513 Modify env_windows_amd64_513/5.13.0/mingw73_64/bin/qtenv2.bat 把set path后面的路径改为env_windows_amd64_513\5.13.0\mingw73_64\bin, cd your qtpath/bin go build ./qtsetup/ go build ./qtminimal/ go build ./qtdeploy/ go build ./qtminimal/ go build ./qtrcc/ run the command in your object path: qtdeploy.exe -qt_dir=the download file path\env_windows_amd64_513 -qt_version=5.13.0 build desktop the exe file name at fisrt you shoud run go mod、go mod vendor

参考:https://blog.csdn.net/halo_hsuh/article/details/106818987