```c // Create a data type: "Pointer to MyClass function" with type name: "funcPtr_t" typedef void (MyClass::*funcPtr_t)(); QListfuncList; // Create a list of pointers funcPtr_t fp = &MyClass::myFunction; // Create a pointer to function "myFunction" with name "fp" funcList.append( fp ); // Add to list for( funcPtr_t func : funcList) // Call all functions in our list (there is only one) { (this->*func)(); // We are calling from an object of the same class } // --------------------------------------------------------------------------------------------- Myclass myObject; for( funcPtr_t func : funcList) // Call all functions in our list (there is only one) { (myObject.*func)(); // We are calling from outside "MyClass" } // --------------------------------------------------------------------------------------------- Myclass* myObject = new Myclass(); for( funcPtr_t func : funcList) // Call all functions in our list (there is only one) { (myObject->*func)(); // We are calling from outside "MyClass" } ```
C++ Pointer to member Function.
Fast linked list without list
If you need a very fast way to iterate over a list of objects and call the same method on all of them, then here is a posible solution. Der...
-
Sometimes is useful resizing a QListWidget to the size of its content. This is one way to do it. Don't forget resizing again when you...
-
Adding a submenu to a QMenu is really easy, and you add nested submenus if you want: ```c QMenu* mainMenu; QAction* action1 = mainMenu...