Re: Context sensitive help
There is QHelpEvent and QWhatsThisClickedEvent and QAssistantClient. If you want to keep all the help related code in one place, I suggest you do it in the application object as all events pass through QCoreApplication. Global coordinates may help you pinpoint the widget under cursor or you may install an event filter somewhere to gather and handle all help events in one place.
Of course the simplest way is just to use What's This architecture.
Re: Context sensitive help
First of all, sorry for not being clear enough.
I have "what's this" texts and tool tips set all around, but that's not what I was talking about when referring to "context sensitive help". What I was talking about was indeed about using QAssistantClient as providing some more verbal help.
One could catch for example key press event for F1 at the application level and launch the Assistant and/or switch the page when required. I though creating a QShortcut with key sequence of QKeySequence::HelpContents was the correct cross-platform approach for triggering the help.
All the context sensitive help related code for finding the correct page in the help documentation is already done at application level, in a QApplication subclass. As mentioned earlier, the correct help page for Assistant is determined according to the current widget (or it's parent / grand parents) containing the focus.
The only problem is that the slot containing the help functionality in the QApplication subclass is not triggered whenever a modal dialog is active. Otherwise it's working as desired.
Re: Context sensitive help
Quote:
Originally Posted by
jpn
what I'm looking for is a decent enough temporary workaround. One not-so-good workaround would be to create a corresponding shortcut for each and every modal dialog. I really wanted to avoid sprinkling the help related code all over the project.
How about deriving your dialogs from a custom Dialog class that will be aware of that shortcut? This way the help-handling code would be only in one place.
Other thing you can try are aspects. You could inject that shortcut object into every class you derive from QDialog and still keep the code outside your main sources.
Re: Context sensitive help
You can install event filters on those dialogs before exec'ing them. That should allow you to intercept the shortcut even if the main (application) event loop is not running. You could then call the slot yourself.