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. QML Connections element works under ApplicationWindow and TabView but does not work in Tab section.
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved QML and Qt Quick
qmlslotsignal
2 Posts 2 Posters 1.5k Views 3 Watching
  • 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 Offline
    A Offline
    a.toraby
    wrote on last edited by
    #1

    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
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      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
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved