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. Android: MouseArea.onClicked doesn't get called
QtWS25 Last Chance

Android: MouseArea.onClicked doesn't get called

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 1.2k Views
  • 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.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on last edited by
    #1

    I have the following QML file:

    import QtQuick 2.7
    import QtQuick.Controls 2.0
    import QtQuick.Layouts 1.3
    import ReaderView 1.0
    
    ApplicationWindow {
        visible: true
    
        MouseArea {
            anchors.fill: parent
    
            onClicked: {
                console.log("onClicked!")
            }
        }
    
        ColumnLayout {
            spacing: 0
            anchors.fill: parent
    
            CReaderView {
                anchors.fill: parent
            }
        }
    }
    

    I'm tapping the screen of the Nexus 7 tablet but onClicked is never printed in the log. I also tried moving the MouseArea inside CReaderView to no avail. What's the deal? How can I detect a tap within the window (or, ideally, within the CReaderView)?

    1 Reply Last reply
    0
    • jeremy_kJ Offline
      jeremy_kJ Offline
      jeremy_k
      wrote on last edited by
      #2

      I wonder if the issue is the output of console.log being filtered out through categorized logging rules. http://doc.qt.io/qt-5/qloggingcategory.html

      Try setting the QT_LOGGING_RULES environment variable to "qml.debug=true".

      Asking a question about code? http://eel.is/iso-c++/testcase/

      V 1 Reply Last reply
      1
      • jeremy_kJ jeremy_k

        I wonder if the issue is the output of console.log being filtered out through categorized logging rules. http://doc.qt.io/qt-5/qloggingcategory.html

        Try setting the QT_LOGGING_RULES environment variable to "qml.debug=true".

        V Offline
        V Offline
        Violet Giraffe
        wrote on last edited by
        #3

        @jeremy_k
        It's Android so I have no idea how to set an environment variable. Instead, I'll just call a C++ method that will use qDebug().
        And turns out you're right! So does it mean I cannot rely on console for debug output from QML and must use my own class instead? Or can this be fixed (other than by adjusting the environment)?

        jeremy_kJ 1 Reply Last reply
        0
        • V Violet Giraffe

          @jeremy_k
          It's Android so I have no idea how to set an environment variable. Instead, I'll just call a C++ method that will use qDebug().
          And turns out you're right! So does it mean I cannot rely on console for debug output from QML and must use my own class instead? Or can this be fixed (other than by adjusting the environment)?

          jeremy_kJ Offline
          jeremy_kJ Offline
          jeremy_k
          wrote on last edited by
          #4

          QLoggingCategory::setFilterRules() is the C++ equivalent of QT_LOGGING_RULES.

          Asking a question about code? http://eel.is/iso-c++/testcase/

          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