I have a QMainWindow with a toolbar with a toolbutton that I use to open a custom assistant for providing context relevant help to the user.
This is a scenario I want to achieve: The user has opened several tools and is currently inputing a value into a spinbox, but wonders what this tool/dialog really does. He presses the questionmark on the main window's toolbar and gets the helpfile for the dialog he is using.
Can someone help me find an elegant way of finding which dialog that currently has focus?
I see that a spinbox in the current tool still has focus and I can get that by:
QApplication::focusWidget();
To copy to clipboard, switch view to plain text mode
If I try this:
QApplication::focusWidget();
To copy to clipboard, switch view to plain text mode
, I get the main window.
I planned to get the current dialog and then use the objectName() to identify which helpfile to open.
I see it as risky business to implement code in all dialogs to try to traverse up to the top parent for that dialog as you are not forced to provide the parent in a constructor. But if nothing else works, I will do that and rather show a default help file if the top dialog for that particular focus widget is not known.
Bookmarks