QML ApplicationWindow unable to use onActiveChanged



  • I am using QT5.7 and Controls 2.0 and I am unable to use onActiveChanged with ApplicationWindow:
    ApplicationWindow {
    id: root
    flags: Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint
    onActiveChanged: {
    //do my stuff
    }
    }
    I am getting
    "Error:qrc:/main.qml:66 "ApplicationWindow.onActiveChanged" is not available due to component versioning.\n"
    I am able to use it with Window, but Window does not support popup dim effect which I need as well.. I do not seem to find anything in documentation on this... I need to be able to detect clicks outside the ApplicationWindow.

    Any help is greatly appreciated


  • Moderators

    Hi! Looks like a bug in the property/revisioning system. You can use the following as a workaround:

    import QtQuick 2.7
    import QtQuick.Controls 2.1
    
    ApplicationWindow {
        id: mainWindow
        visible: true
        width: 640
        height: 480
    
        Connections {
            target: mainWindow
            onActiveChanged: {
                console.log("onActiveChanged: " + mainWindow.active);
            }
        }
    }
    

    Please file a bug at bugreports.qt.io.

    [Ping @jpnurmi]



  • @Wieland Thank you so much. I can't believe how simple the workaround was... I've been struggling with this one for a while... I'll log a bug



  • Hi, this was fixed in the 5.9 branch just a while ago. The fix will be available in Qt 5.9.1.



  • @jpnurmi Thank you!


Log in to reply
 

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