Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

menu.Actions() panics #1286

Open
ilius opened this issue Mar 29, 2023 · 0 comments
Open

menu.Actions() panics #1286

ilius opened this issue Mar 29, 2023 · 0 comments

Comments

@ilius
Copy link

ilius commented Mar 29, 2023

menu.Actions() panics for me.
My code:

webBrowser.ConnectContextMenuEvent(func(event *gui.QContextMenuEvent) {
	event.Ignore()
	menu := webBrowser.CreateStandardContextMenu()
	actions := menu.Actions()
	fmt.Println("actions", actions)
	// menu.Actions() panics
	// firstAction := actions[0]
	action := widgets.NewQAction2("Query", webBrowser)
	action.ConnectTriggered(func(checked bool) {
		text := webBrowser.TextCursor().SelectedText()
		if text != "" {
			doQuery(text)
		}
	})
	menu.InsertAction(nil, action)
	menu.Popup(event.GlobalPos(), nil)
})

I want to pass menu.Actions()[0] to menu.InsertAction.

Traceback:

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

goroutine 74 [running]:
github.com/therecipe/qt/widgets.(*QWidget).Actions(0xc0021c8570?)
        go/pkg/mod/github.com/therecipe/qt@v0.0.0-20200904063919-c0c124a5770d/widgets/widgets.go:58418 +0x152
github.com/ilius/ayandict/pkg/application.Run.func10(0xc002a90de0)
        go/src/github.com/ilius/ayandict/pkg/application/app.go:257 +0x51
reflect.Value.call({0x1644740?, 0xc0002d3db8?, 0x1cfb360?}, {0x191f87d, 0x4}, {0xc002a90dc8, 0x1, 0x5fabfe0?})
        Go/src/reflect/value.go:584 +0x8c5
reflect.Value.Call({0x1644740?, 0xc0002d3db8?, 0xc002ad4030?}, {0xc002a90dc8?, 0x17463c0?, 0x0?})
        Go/src/reflect/value.go:368 +0xbc
github.com/therecipe/qt/internal.handleCallback({0xc002bdaee6, 0x65})
        go/pkg/mod/github.com/therecipe/qt@v0.0.0-20200904063919-c0c124a5770d/internal/internal.go:73 +0x2fd
github.com/therecipe/qt/internal.asyncCallbackHandler({0xc002bdaee6?, 0x0?})
        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
        go/pkg/mod/github.com/therecipe/qt@v0.0.0-20200904063919-c0c124a5770d/internal/internal.go:407 +0xf5
ilius added a commit to ilius/qt that referenced this issue Apr 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant