QQuickView not active before being clicked once



  • Hi
    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 ?
    Thank you


  • Moderators

    Hi,

    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.
    Thank you



  • Upsss....
    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


  • Moderators

    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.


  • Moderators

    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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.