[SOLVED]Access fathers public function from children
i have made in child pointer of father and try to call one public function of him. But it tells me that QWidget(father type) dont have that function. In which way i can call fathers public function?
Small example of what i have in childen class:
QWidget *keepFather = parent;
keepFather->setWindowFlags(keepFather->windowFlags() ^ Qt::WindowStaysOnTopHint); //That's working normaly because that function is from QWidget
keepFather->changeThings(8); //That's not working, it's from public function of father's pointer
if the class is derived from a QWidget the QWidget would be the parent (father) class, so it doesn't inherit any of the properties of the child class.
edit:: In order to resolve your problem you would have to cast the keepFather pointer to that of the child class, or declare keepFather as a pointer to the child class.
Yes, i was thinking something like that, but still working on making pointer of father class. I dont see how can i make include parent class to build pointer of parent object.
To avoid having such coupling, you should rather use signals and slots to update the parent content based on the child actions. So the child doesn't need to know it's parent class.
Ok i think i have to search there, thx. How to set post Solved?
[quote author="SGaist" date="1379965124"]Hi,
To avoid having such coupling, you should rather use signals and slots to update the parent content based on the child actions. So the child doesn't need to know it's parent class.[/quote]
That is done by editing your first post, there you can update the title :)
Happy coding !