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. Can signal slot used as new thread?

Can signal slot used as new thread?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 376 Views 2 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
    Abhishek2509
    wrote on last edited by
    #1

    Option 1:
    Void read(buffer)// this read data every second
    (
    displayData(buffer);// display data at QT screen
    )// end of function

    Option 2:
    Void read(buffer)
    (
    emit signalData(buffer)
    )
    connect(this,SIGNAL,signalData(buffer),this,SLOT(displayData(buffer));//defined in constructor

    Therr is no difference in display data. But just want to know which is better in terms of processing.

    Any better suggestions.....
    Thanks

    ODБOïO 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      The rule is: do not directly modify GUI elements form a different thread. Use signals and slots to communicate.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • A Abhishek2509

        Option 1:
        Void read(buffer)// this read data every second
        (
        displayData(buffer);// display data at QT screen
        )// end of function

        Option 2:
        Void read(buffer)
        (
        emit signalData(buffer)
        )
        connect(this,SIGNAL,signalData(buffer),this,SLOT(displayData(buffer));//defined in constructor

        Therr is no difference in display data. But just want to know which is better in terms of processing.

        Any better suggestions.....
        Thanks

        ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #3

        @Abhishek2509 said in Can signal slot used as new thread?:

        connect(this,SIGNAL,signalData(buffer),this,SLOT(displayData(buffer));/

        Here the sender is "this" and the receiver is "this" as well, so to me this still doas not respect the rule stated by @SGaist, correct me if i'm wrong.

        Also, you are useing old signal/slot syntax : https://wiki.qt.io/New_Signal_Slot_Syntax

        1 Reply Last reply
        1

        • Login

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