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. How to add new event to qt default event loop?

How to add new event to qt default event loop?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.2k Views
  • 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.
  • M Offline
    M Offline
    Mr Pang
    wrote on 14 May 2018, 13:48 last edited by
    #1

    I have a few file descriptors, in c, I can use poll() to monitor them in a single thread. Now I would like to learn how to use Qt to monitor them, using default eventloop.

    Can anyone teach me?

    Thanks!!

    K 1 Reply Last reply 14 May 2018, 14:43
    0
    • G Offline
      G Offline
      Gojir4
      wrote on 14 May 2018, 13:56 last edited by
      #2

      Hello,

      I think you need to use Signals and Slots. Which are the easiest way with Qt to propagate event between threads.

      If your goal is to monitor file changes, you may consider using QFileSystemWatcher which is already designed to monitor changes in files and/or folders.

      1 Reply Last reply
      3
      • M Mr Pang
        14 May 2018, 13:48

        I have a few file descriptors, in c, I can use poll() to monitor them in a single thread. Now I would like to learn how to use Qt to monitor them, using default eventloop.

        Can anyone teach me?

        Thanks!!

        K Offline
        K Offline
        kshegunov
        Moderators
        wrote on 14 May 2018, 14:43 last edited by
        #3

        @Mr-Pang said in How to add new event to qt default event loop?:

        I have a few file descriptors, in c, I can use poll() to monitor them in a single thread. Now I would like to learn how to use Qt to monitor them, using default eventloop.

        You can use QSocketNotifier (despite the name) to do that. When the descriptor's activated for reading or writing (depending on what you passed to the constructor) the activated signal will be raised for you.

        Read and abide by the Qt Code of Conduct

        M 1 Reply Last reply 15 May 2018, 12:02
        5
        • K kshegunov
          14 May 2018, 14:43

          @Mr-Pang said in How to add new event to qt default event loop?:

          I have a few file descriptors, in c, I can use poll() to monitor them in a single thread. Now I would like to learn how to use Qt to monitor them, using default eventloop.

          You can use QSocketNotifier (despite the name) to do that. When the descriptor's activated for reading or writing (depending on what you passed to the constructor) the activated signal will be raised for you.

          M Offline
          M Offline
          Mr Pang
          wrote on 15 May 2018, 12:02 last edited by
          #4

          @kshegunov
          Great

          1 Reply Last reply
          0

          2/4

          14 May 2018, 13:56

          • Login

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