{"action":"created","issue":{"url":"https://api.github.com/repos/therecipe/qt/issues/83","repository_url":"https://api.github.com/repos/therecipe/qt","labels_url":"https://api.github.com/repos/therecipe/qt/issues/83/labels{/name}","comments_url":"https://api.github.com/repos/therecipe/qt/issues/83/comments","events_url":"https://api.github.com/repos/therecipe/qt/issues/83/events","html_url":"https://github.com/therecipe/qt/issues/83","id":185385309,"number":83,"title":"QMetaMethod::invoke: Unable to handle unregistered datatype 'QSystemTrayIcon::MessageIcon'","user":{"login":"microo8","id":1846338,"avatar_url":"https://avatars.githubusercontent.com/u/1846338?v=3","gravatar_id":"","url":"https://api.github.com/users/microo8","html_url":"https://github.com/microo8","followers_url":"https://api.github.com/users/microo8/followers","following_url":"https://api.github.com/users/microo8/following{/other_user}","gists_url":"https://api.github.com/users/microo8/gists{/gist_id}","starred_url":"https://api.github.com/users/microo8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/microo8/subscriptions","organizations_url":"https://api.github.com/users/microo8/orgs","repos_url":"https://api.github.com/users/microo8/repos","events_url":"https://api.github.com/users/microo8/events{/privacy}","received_events_url":"https://api.github.com/users/microo8/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-26T12:55:45Z","updated_at":"2016-10-26T14:59:50Z","closed_at":null,"body":"when I'm calling [`QSystemTrayIcon::showMessage`](http://doc.qt.io/qt-5/qsystemtrayicon.html#showMessage) from other goroutine than the main, it doesn't show the balloon message and prints this warning:\r\n`QMetaMethod::invoke: Unable to handle unregistered datatype 'QSystemTrayIcon::MessageIcon'`\r\n\r\nI'm calling it like this: `systray.ShowMessage(\"title\", \"message\", widgets.QSystemTrayIcon__Information, 5000)`\r\n\r\nwhere is the problem?"},"comment":{"url":"https://api.github.com/repos/therecipe/qt/issues/comments/256374229","html_url":"https://github.com/therecipe/qt/issues/83#issuecomment-256374229","issue_url":"https://api.github.com/repos/therecipe/qt/issues/83","id":256374229,"user":{"login":"therecipe","id":9833226,"avatar_url":"https://avatars.githubusercontent.com/u/9833226?v=3","gravatar_id":"","url":"https://api.github.com/users/therecipe","html_url":"https://github.com/therecipe","followers_url":"https://api.github.com/users/therecipe/followers","following_url":"https://api.github.com/users/therecipe/following{/other_user}","gists_url":"https://api.github.com/users/therecipe/gists{/gist_id}","starred_url":"https://api.github.com/users/therecipe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/therecipe/subscriptions","organizations_url":"https://api.github.com/users/therecipe/orgs","repos_url":"https://api.github.com/users/therecipe/repos","events_url":"https://api.github.com/users/therecipe/events{/privacy}","received_events_url":"https://api.github.com/users/therecipe/received_events","type":"User","site_admin":false},"created_at":"2016-10-26T14:59:50Z","updated_at":"2016-10-26T14:59:50Z","body":"Hey\r\n\r\nThis is strange, `QSystemTrayIcon::showMessage` is labeled as `slot` and should be able to cross threads without problems. I will look into this.\r\n\r\nBut the example below should work.\r\nYou just need to create a custom slot in as subclass of `widgets.QSystemTrayIcon` to wrap your functions calls, if you want to cross threads. \r\nOr use the \"safe\" functions labeled `slot` in the Qt docs (even through `QSystemTrayIcon::showMessage` didn't work in that particular case).\r\n\r\nYou can also take a look at the `qml/bridge` examples to see how your can use slots and signals with parameters and you may want to read http://doc.qt.io/qt-5/signalsandslots.html.\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n\t\"os\"\r\n\r\n\t\"github.com/therecipe/qt/widgets\"\r\n)\r\n\r\ntype QSystemTrayIconWithCustomSlot struct {\r\n\twidgets.QSystemTrayIcon\r\n\r\n\t_ func() `slot:triggerSlot`\r\n}\r\n\r\nfunc main() {\r\n\twidgets.NewQApplication(len(os.Args), os.Args)\r\n\r\n\tvar (\r\n\t\twidget       = widgets.NewQWidget(nil, 0)\r\n\t\twidgetLayout = widgets.NewQVBoxLayout()\r\n\t)\r\n\twidget.SetLayout(widgetLayout)\r\n\r\n\tvar systray = NewQSystemTrayIconWithCustomSlot(nil)\r\n\tsystray.SetIcon(widget.Style().StandardIcon(widgets.QStyle__SP_MessageBoxCritical, nil, nil))\r\n\r\n\tvar systrayMenu = widgets.NewQMenu(nil)\r\n\tsystrayMenu.AddAction(\"first action\")\r\n\tsystrayMenu.AddAction(\"second action\")\r\n\tsystray.SetContextMenu(systrayMenu)\r\n\r\n\tsystray.Show()\r\n\r\n\t//works\r\n\tvar buttonMain = widgets.NewQPushButton2(\"call from main thread\", nil)\r\n\tbuttonMain.ConnectClicked(func(bool) {\r\n\t\tsystray.ShowMessage(\"title\", \"main thread message\", widgets.QSystemTrayIcon__Information, 5000)\r\n\t})\r\n\twidgetLayout.AddWidget(buttonMain, 0, 0)\r\n\r\n\t//fails\r\n\tvar buttonOther = widgets.NewQPushButton2(\"call from other thread\", nil)\r\n\tbuttonOther.ConnectClicked(func(bool) {\r\n\t\tgo func() {\r\n\t\t\tsystray.ShowMessage(\"title\", \"other thread message\", widgets.QSystemTrayIcon__Information, 5000)\r\n\t\t}()\r\n\t})\r\n\twidgetLayout.AddWidget(buttonOther, 0, 0)\r\n\r\n\t//works\r\n\tvar buttonSlot = widgets.NewQPushButton2(\"call from other thread with slot\", nil)\r\n\tsystray.ConnectTriggerSlot(func() {\r\n\t\tsystray.ShowMessage(\"title\", \"other thread message with slot\", widgets.QSystemTrayIcon__Information, 5000)\r\n\t})\r\n\tbuttonSlot.ConnectClicked(func(bool) {\r\n\t\tgo func() {\r\n\t\t\tsystray.TriggerSlot()\r\n\t\t}()\r\n\t})\r\n\twidgetLayout.AddWidget(buttonSlot, 0, 0)\r\n\r\n\twidget.Show()\r\n\r\n\twidgets.QApplication_Exec()\r\n}\r\n```"}}
{"actor":{"display_login":"therecipe"}}