
Originally Posted by
taylor34
I'd like to do that class cast, but I can't because my child widget class has no knowledge of the parent class (i.e. I'm not including the parent.h file or anything).
When you are starting to put those little arrows one after the other the compiler generates indermediate objects / pointers to objects, so not including the interface of the generated objects the compiler won't know what to do and also you can only have access to the public interface:
parent()->DoSomething();
parent()->DoSomething();
To copy to clipboard, switch view to plain text mode
is actually
temp->DoSomething(); // boom
QObject * temp = parent();
temp->DoSomething(); // boom
To copy to clipboard, switch view to plain text mode
while you need
#include "myform.h"
//...
MyForm *temp = (MyForm *)parent();
temp->DoSomething()
#include "myform.h"
//...
MyForm *temp = (MyForm *)parent();
temp->DoSomething()
To copy to clipboard, switch view to plain text mode
Bookmarks