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?
QtWS25 Last Chance

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 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!!

    kshegunovK 1 Reply Last reply
    0
    • Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on 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

        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!!

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on 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
        5
        • kshegunovK kshegunov

          @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 last edited by
          #4

          @kshegunov
          Great

          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