Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    QML Connections element works under ApplicationWindow and TabView but does not work in Tab section.

    QML and Qt Quick
    qml slot signal
    2
    2
    1310
    Loading More Posts
    • 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.
    • A
      a.toraby last edited by

      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");
                  }
              }
      ....
      
      1 Reply Last reply Reply Quote 0
      • p3c0
        p3c0 Moderators last edited by

        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")
                    }
                }
            }
        }
        
        

        157

        1 Reply Last reply Reply Quote 0
        • First post
          Last post