generic variable type?



  • hi.
    is there a variable type that can hold a pointer to any type of oblect, like id in OSX?

    i want to add a myButton (subclass of QWidget) to an instane of another subclass of QWidget, and they need to communicate. problem is that i can't predict what type of object myButton will be added to. could be a screen or a buttonBar or some other subclass of QWidget i haven't even thought of yet. so how can i make sure they can communicate? communication is required so that the screen can tell the button what size, shape and color the button should be and what text it should display.



  • Hi,
    I don't know if I got you right, but I think void* pointer will do it for you.



  • If I do understand correctly then QWidget* is enough.
    All Ui drawable elements are QWidget base and If You are looking only for base widget functionality like size, with is accessible in QWidget, then that's fine, if You want custom interaction, i.e. myButton overwrites size and defined completely new behavior or there are custom signals etc., then on that QWidget pointer do cast to defined type and then just work with that object.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.