generic variable type?
-
wrote on 27 Sept 2015, 00:51 last edited by
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.
-
wrote on 27 Sept 2015, 07:49 last edited by
Hi,
I don't know if I got you right, but I thinkvoid*
pointer will do it for you. -
wrote on 27 Sept 2015, 12:13 last edited by
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.
1/3