
Originally Posted by
franco.amato
How can I do that? I would learn something new!
Very simple, just keep calling parent() till it returns 0 or if you use the metadata or name of the object and you find what you wanted.
That said, I don't think this is a good idea.
Simply I need to enable/disable an action created in the QMainWindow from the QWidgets.
In such cases I always use a signal/slot combo or an event.
MainWindow -> acts to widget1 signal in a slot
|
+---- Central widget
|
+---- Widget 1 -> sends a signal to the main window
|
+---- Widget 2
connect(widget1, SIGNAL(widget1ActionEnabled(bool)), mainwindow, SLOT(slotWidget1ActionEnabled(bool)));
MainWindow -> acts to widget1 signal in a slot
|
+---- Central widget
|
+---- Widget 1 -> sends a signal to the main window
|
+---- Widget 2
connect(widget1, SIGNAL(widget1ActionEnabled(bool)), mainwindow, SLOT(slotWidget1ActionEnabled(bool)));
To copy to clipboard, switch view to plain text mode
Or something similar to that. You only need to add a signal to your widget, emit it at the correct time and implement a very simple slot in your main window.
Bookmarks