Important: Please read the Qt Code of Conduct -

[SOLVED] Is onExited: name2.state = "" valid? (State changes using onExited with hover enabled on mouse areas)

  • Hi guys,

    Hopefully a quick one:

    Say we have have an item with id of 'name2' and two states of 'default' and 'State1' Over that we apply:

    MouseArea {
    id: name
    width: name2.width
    height: name2.height
    opacity: 0
    hoverEnabled: true
    onExited: name2.state = ""

    Alas this seems to have no effect. Have I made a syntax error? Or is there a better way to do this? I have affected image sources using onHover and Exit to good effect on menus and other items just fathoming how to use the same idea to effect states.

    Thanks for your help.

    If anyone wants to code model for using hover to change image for their menus let me know and will post.

    [EDIT: code formatting, please wrap in @-tags, Volker]

  • Hi QtQitten, it should work. Show us a complete example so we can say more. BTW, remove opacity:0 from MouseArea because it is not needed here and it may cause such a behavior

  • If you set <code>opactiy: 0</code> on a MouseArea it won't recieve any events.

  • Unsure where that opacity snuck in... Code is behaving normally now. I am surprised MouseArea accepts an opacity value where it has this effect.

    Thank's for the sanity check both.

Log in to reply