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. Qt's alternative for std::function
Forum Updated to NodeBB v4.3 + New Features

Qt's alternative for std::function

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 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
    mhn2
    wrote on 26 Sept 2022, 07:52 last edited by
    #1

    I personally hate function pointers, they make me have a headache. Luckily std::function is here for the rescue. Its syntax is simple and it handles deconstructing, copying and moving for you.
    A lot of the things provided by std usually have an alternative in Qt (for a example std::vector and QList, std::pair and QPair, the <random> library and QRandomGenerator and etc.) I will always try to use the Qt's alternative because they have more functionality and I'm sure they are compatible with the shenanigans that Qt is doing behind the scenes.
    Is there an alternative to std::function in Qt? If not, is std::function compatible with Qt's shenanigans?

    C 1 Reply Last reply 26 Sept 2022, 10:57
    0
    • M mhn2
      26 Sept 2022, 07:52

      I personally hate function pointers, they make me have a headache. Luckily std::function is here for the rescue. Its syntax is simple and it handles deconstructing, copying and moving for you.
      A lot of the things provided by std usually have an alternative in Qt (for a example std::vector and QList, std::pair and QPair, the <random> library and QRandomGenerator and etc.) I will always try to use the Qt's alternative because they have more functionality and I'm sure they are compatible with the shenanigans that Qt is doing behind the scenes.
      Is there an alternative to std::function in Qt? If not, is std::function compatible with Qt's shenanigans?

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 26 Sept 2022, 10:57 last edited by
      #2

      @mhn2 said in Qt's alternative for std::function:

      Is there an alternative to std::function in Qt?

      No, there is no such a need to mimic std::function

      If not, is std::function compatible with Qt's shenanigans?

      It's both c++, so yes.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3

      1/2

      26 Sept 2022, 07:52

      • Login

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