Qt's alternative for std::function
-
wrote on 26 Sept 2022, 07:52 last edited by
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? -
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?@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.
1/2