Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML MouseArea - Mouse Is Not Defined
Forum Updated to NodeBB v4.3 + New Features

QML MouseArea - Mouse Is Not Defined

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 799 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KidBuu
    wrote on last edited by KidBuu
    #1

    I'm working with QML for the first time in a long time and I noticed something while working with MouseAreas... I need to make it propagate through the MouseArea and eventually trigger a ComboBox to open up. I do this by using mouse.accepted = false on the MouseArea event that I catch (onPressed).

    This worked perfectly fine when running the program with the Qt Debugger, but when running without the Debugger (even when running the standalone application, running the application as admin, and running the creator as admin), I get the following error. Note this happens even with other MouseArea events (such as onClicked).

    ReferenceError: mouse is not defined
    

    Is this a bug or am I doing something wrong here...? I am using Qt 5.15 and creator 4.15.0 (https://puu.sh/IGdRy/c8760bf2d8.png)

    I was able to reproduce the issue with VERY minimal code...

    import QtQuick 2.15
    import QtQuick.Window 2.15
    import QtQuick.Controls 2.12
    import QtQuick.Layouts 1.12
    
    Window {
        width: 640
        height: 480
        visible: true
    
        MouseArea {
            anchors.fill: parent
            propagateComposedEvents: true
    
            onPressed: function () {
                mouse.accepted = false
                console.log("Hit, but mouse doesn't exist?");
            }
        }
    }
    

    The issue is pretty self explanatory, but here's a short clip of the issue happening.
    [https://puu.sh/IGdXd/66252c6d30.mp4](link url)

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2
      MouseArea {
              anchors.fill: parent
              propagateComposedEvents: true
      
              onPressed: {
                  mouse.accepted = false
                  console.log("Hit, but mouse doesn't exist?");
              }
          }
      

      You don't need "function()". If for some reason you want function it should accept a parameter: function(mouse). However, I don't even know if that would work.

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      1
      • K Offline
        K Offline
        KidBuu
        wrote on last edited by
        #3

        @fcarney said in QML MouseArea - Mouse Is Not Defined:

        mouse

        Wow that worked, thanks! Really should throw a warning or something that the parameters don't matchup with the signal.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved