qt icon indicating copy to clipboard operation
qt copied to clipboard

menu.Actions() panics

Open ilius opened this issue 1 year ago • 0 comments

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/[email protected]/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/[email protected]/internal/internal.go:73 +0x2fd
github.com/therecipe/qt/internal.asyncCallbackHandler({0xc002bdaee6?, 0x0?})
        go/pkg/mod/github.com/therecipe/[email protected]/internal/internal.go:109 +0x1e
created by github.com/therecipe/qt/internal.InitProcess.func3
        go/pkg/mod/github.com/therecipe/[email protected]/internal/internal.go:407 +0xf5

ilius avatar Mar 29 '23 11:03 ilius