Create F1 key in tooltip (similar to qtcreator)



  • Hi,

    I have been searching for the past few days but I cannot figure out on how to do it. I would like to do reproduce a behavior similar to the newest qtcreator where a F1 hint is shown in tooltip and allows you to show full help in a context sensitive manner by pressing F1 while the tooltip is displayed.

    Has anyone tried yet to get the same tooltip feature in their programs?

    Cheers,
    Rno



  • I haven't done it in action but this might give you some hint

    Implement "hoverEvent" on your editor

    Look for the word below the mouse (e.g. QTextCursor::WordUnderCursor is a possible way)

    You should have some "keywords" to check if it points to a specific "help/tooltip" (it is up to you to implement)

    Implement "keyPressEvent" and wait for "Qt::Key_F1"

    The rest is up to you...

    Cheers!!!



  • I have the downstream documentation files in qt format and it works well with my kewords. But isn't QTextCursor only for QTextDocument? I want to act on widgets tooltips.

    Anyone else with some ideas?



  • Nope, it is supported by "QTextEdit":http://qt-project.org/doc/qt-4.8/qtextedit.html, etc. (AFAIK, all Qt classes that were designed to edit texts support this)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.