Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Showcase
  4. Javascript-like Promises
Forum Updated to NodeBB v4.3 + New Features

Javascript-like Promises

Scheduled Pinned Locked Moved Unsolved Showcase
3 Posts 2 Posters 631 Views 1 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.
  • F Offline
    F Offline
    flaviotordini
    wrote on 15 May 2024, 06:41 last edited by
    #1

    Hi all, I just discovered this forum section and I thought I would post a small library I created to be able to do async programming easily with Qt.

    https://github.com/flaviotordini/promises

    I would really love to know how you're doing async (not multithreaded!) programming in Qt. For example, do you use QFuture? How?

    J 1 Reply Last reply 15 May 2024, 07:01
    0
    • F flaviotordini
      15 May 2024, 06:41

      Hi all, I just discovered this forum section and I thought I would post a small library I created to be able to do async programming easily with Qt.

      https://github.com/flaviotordini/promises

      I would really love to know how you're doing async (not multithreaded!) programming in Qt. For example, do you use QFuture? How?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 15 May 2024, 07:01 last edited by
      #2

      @flaviotordini said in Javascript-like Promises:

      how you're doing async (not multithreaded!) programming in Qt

      By using signals and slots. Qt is an asynchronous framework. Most of the time you don't have to deal with threads.

      "For example, do you use QFuture? How?" - QFuture is only needed if you're working with threads, which you do not want to. How to use it is explained in the documentation: https://doc.qt.io/qt-6/qfuture.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • F Offline
        F Offline
        flaviotordini
        wrote on 15 May 2024, 07:36 last edited by
        #3

        I'm very aware of signals and slots. IMO JS-like promises solve a slightly different problem. Qt signals are shared among all subscribers. Promises are specific to a single function call.

        In my lib I implemented promises using signal and slots. The difference is that there is a new QObject for each function call. In my experience this prevents potential issues with clients connecting to the same signal in the same object and then receiving multiple signals or having to manually disconnect after the first signal...

        Also signals and slots are scattered in the class header and in many functions, while the promise approach is more self-contained.

        1 Reply Last reply
        1

        1/3

        15 May 2024, 06:41

        • Login

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