w4r1o
25th March 2011, 21:29
Hi guys, I have a question. I'm making a widget (let's call it myWidget) which inherits from QWidget and my window widget (the top one in the parent hierarchy) is a MainWindow (made by me) which inherits from QMainWindow. The question is, why something like this doesn't work ?
class myWidget : public QWidget {
...
public:
myWidget(QWidget* parent =0) {}
...
};
// a slot I made
void myslot() {
...
MainWindow* p = static_cast<MainWindow*>(window());
...
}
The cast doesn't work, even with a dynamic_cast its the same. Why ?
class myWidget : public QWidget {
...
public:
myWidget(QWidget* parent =0) {}
...
};
// a slot I made
void myslot() {
...
MainWindow* p = static_cast<MainWindow*>(window());
...
}
The cast doesn't work, even with a dynamic_cast its the same. Why ?