Hi, I'm writing a library which I have currently connected to a Qt application that works as a GUI for the library. The library needs to be provided with a callback function and also a parameter in the form of a void pointer. When the library wants to provide the user with information, it calls the callback function and sends it two parameters, 1: The pointer the library was provided with along with the callback function, and 2: The string to be displayed to the user. The idea with the void pointer is that it can point to a class object in order to make it possible to access non-static members of that class, which is not possible otherwise.
Now to my question: Is it possible to create a slot with Qt in some way, in order to make this callback type safe? After all, I don't want to have to receive a void pointer which I may forget what it is for, convert to the wrong kind of pointer and use for the wrong purpose. This non-type safe programming would not either generate a warning (I assume). Instead, I want to wrap this all up in some way, in order to prevent getting back a void pointer. Maybe I could instead get back a pointer to the kind of object I really want to access.
Bookmarks