Results 1 to 5 of 5

Thread: Context sensitive help

  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Context sensitive help

    Hello,

    What kind of mechanisms do you people use for building context sensitive helps into Qt applications?

    My idea was to create a single application wide shortcut (Qt::ApplicationShortcut). In the slot connected to the shortcut my plan was to act according to the QApplication::focusWidget(). Everything was working smooth until I noticed that modal dialogs prevent the shortcut from getting activated. The shortcut event gets lost somewhere in the event loop run by the modal dialog and the shortcut never gets activated. I would have expected that an application wide shortcut gets activated even when there's a modal dialog running it's own event loop.

    Nevertheless, I have already reported the issue to TT. But now 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.

    So, just curious, how do you people do it?
    J-P Nurmi

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default 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.
    J-P Nurmi

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Context sensitive help

    Quote Originally Posted by jpn View Post
    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.

Similar Threads

  1. Context Menu on QTableWidget
    By ankurjain in forum Qt Programming
    Replies: 9
    Last Post: 17th December 2009, 09:52
  2. context menu advice
    By larry104 in forum Qt Programming
    Replies: 1
    Last Post: 4th October 2006, 07:55
  3. help on openGL context
    By mickey in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2006, 19:21
  4. Qt's optimized OpenGL context switching
    By sverhoff in forum Qt Programming
    Replies: 0
    Last Post: 28th March 2006, 16:40
  5. Context OpenGL
    By mickey in forum Qt Programming
    Replies: 4
    Last Post: 3rd March 2006, 21:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.