Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-124654

qml should provide methods to accept signals from different threads

    XMLWordPrintable

Details

    Description

      i am confused about how to directly make connection from different thread c++ objects to qml.

      qml does not seem to be able to directly handle signals from different thread objects, and is it possible to provide queue connection parameters (like the 5th parameter of QObject::connect) to accommodate this requirement.

      in some cases, i want focus on the work completion of different job-QObjects that are used to complete time-consuming work. the c++ qobjects was firstly set context to QQmlApplicationEngine after they constructed, and emit their signals to when abort, pause or finish(...) the jobs. if i directly make connection to these signals from the non-GUI thread objects then occurs qt assert(classic bugs of different thread connections), i could be able to forward the signal in GUI thread by auxiliary object but, there TOO MANY repeated signal definition and forwarding works to do!

       

      here a single example , i must note that there too many same examples

       

      /example qml code begin/

      Connections {

        target: sessionUnit // it was a c++ work thread object

        onConnectCompleted: { // occurs ERROR at here

          if(!result) console.error(qsTr("连接到%1:%2发生错误:%3") .arg(ipv4).arg(port).arg(error))

          else console.log(qsTr("连接成功√ id=%1, key=%2").arg(sessionid).arg(serverPubKey))

        }

      }

      /example qml code end/

       

      can we add a property value 'type' as the next:

      Connections {

        target: sessionUnit // it was a c++ work thread object

        type: Qt.QueueConnection // this is what i hopes: tell qml catch signal and queued activate slot function(s) or, make all qml connections in queued as default

      ...

       

       i have tried searching and sloving this confusion without any effective result, now report.

      thanks.

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qtqmlteam Qt Qml Team User
            lix xing Li
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes