Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QQuickView not active before being clicked once
I have a QSystemTrayIcon based TrayIcon app with a QQuickView object (its source is a QML file) built in main() function.
By clicking in the notification message at tray icon when it appears the view is shown, but I have to click the view once somewhere, and on second click its elements (buttons) work as expected. I mean, mouse click on a button inside the view does not trigger button actions if I haven't previously clicked on some other place in the view.
If I launch the window directly from main(), buttons perfectly work , but not when is shown from the slot associated with the tray icon notification. I´ve tried several changes both in QML ( focus:true, FocusScope...) and C++ ( pView->requestActivate( ) ) but nothing works.
Do you know why ?
Can you try setting focus using setFocus for the root item (i.e QQuickItem) ?
Works.How easy it was!
I was setting focus in a root inner element.
Does not work...Only works if window is previously maximize. Somehow, maximize operations set focus on it before show() .If I show window no maximized, still fails
So if the window is shown maximized then no need to click to activate it ?
Yes, that it is. Quite logical, if a widow is maximized, it must have focus.
Not sure but did you try raise() ?
No, raise() does not help.
I´ve tried lots of things on QQuickItem , setFocus, forceActiveFocus, setAcceptedMouseButtons...and even sending MouseButtonPress/Release events. But nothing works...
Thans for your help.