Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QThread or QTimer
Qt 6.11 is out! See what's new in the release blog

QThread or QTimer

Scheduled Pinned Locked Moved General and Desktop
qthreadqtimer
3 Posts 3 Posters 1.5k 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.
  • P Offline
    P Offline
    PabloAmunt
    wrote on last edited by
    #1

    Hi, I'm writing a GUI programme that receives and sends some data through serial port.

    I'm using the approach showed in the Qt documentation where data is read when a readyRead signal is emitted, and I do this in the mainwindow.

    But now, I want to write data every 50 ms, so I thought about using the QTimer class. However I don't know if this is a good idea. Besides, I've read that it's a better advice to do this kind of processing in a separated thread, in the background, and leave the UI for simpler tasks.

    So, which approach do you think it's a better practice?

    Thanks

    1 Reply Last reply
    0
    • L Offline
      L Offline
      Leonardo
      wrote on last edited by
      #2

      Hi. I think it's all right to use a QTimer, because QSerialPort is a buffered device. Calling the write method will not block your main thread. Give it a try. If you feel some performance decrease, then you may start considering using threads.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tommego
        wrote on last edited by
        #3

        I use qml to make it work.WorkerScript

        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