I think franco's "problem" is that QWidget::parentWidget() returns a pointer to QWidget and he doesn't know how to make it a pointer to QMainWindow. Another one of those C++ problems![]()
I think franco's "problem" is that QWidget::parentWidget() returns a pointer to QWidget and he doesn't know how to make it a pointer to QMainWindow. Another one of those C++ problems![]()
Dear Wysota sorry but you're wrong ( I perfectly know what a cast is ). You are used to underestimate me.
tbscope the problem is that QMainWindow doesn't see directly the QWidget.
The QWidgets are created in the centralWidget class that's part of the QMainWindow class.
I use Visual studio.
Thank you.
Franco
Franco Amato
So QWidget::parentWidget() doesn't work for you? I don't really see the problem... If your widget is a child of a central widget of the main window then obviously:
1. main window is the grand parent of your widget (parentWidget()->parentWidget())
2. main window is a window of your widget (this->window())
Choose either of the two approaches.
I do not underestimate you, it's just sometimes it is hard to see what you actually have a problem with.
Hi franco,
It seems your main window knows both the widgets, so you can simply connect some signal from widgets in main window and act upon them in a slot created in Main window.
If you want to do it otherway round, you should definitely have access to Main window from widgets and for that you either need to pass it or you need to find it walking through parentWidget tree or it should be globally accessible.
Manoj
Bookmarks