Android: MouseArea.onClicked doesn't get called



  • 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)?



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



  • @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)?



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


Log in to reply
 

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