QML Connections element works under ApplicationWindow and TabView but does not work in Tab section.
-
QML Connections element works under ApplicationWindow and TabView but does not work in Tab section.
Here I have a signal in c++ side:modelChanged
In QML I have this connection:
Connections{ target: MainViewMgr onModelChanged: { console.log("new model recived"); } }
It works when I put th connections element in directly under ApplicationWindow or TabView. For example this works:
ApplicationWindow { id: mainWindow width: Screen.desktopAvailableWidth height: Screen.desktopAvailableWidth visible: true TabView{ anchors.fill: parent Connections{ target: MainViewMgr onModelChanged: { console.log("new model recived"); } } ...
But I need to place it under Tab element. When I try this code it does not work. I mean it does not recieve the signal. Why???????
ApplicationWindow { id: mainWindow width: Screen.desktopAvailableWidth height: Screen.desktopAvailableWidth visible: true TabView{ anchors.fill: parent Tab{ title: "RealTime" anchors.fill: parent anchors.margins: 10 Connections{ target: MainViewMgr onModelChanged: { console.log("new model recived"); } } ....
-
Hi,
Tabs are lazily loaded. Have you made sure it is loaded already when you expect the signal ? See following example:
import QtQuick 2.4 import QtQuick.Controls 1.1 Rectangle { width: 200 height: 200 visible: true Button { id: button z:1 anchors.bottom: parent.bottom anchors.right: parent.right text: "Press Me" } TabView { id: tabview anchors.fill: parent Tab { title: "Tab1" } Tab { title: "Tab2" Connections { target: button onClicked: console.log("Button Pressed") } } } }