Links and ToolTips per word in QPlainTextEdit



  • I'm trying to design a log / console widget for a text rpg I'm making.
    Currently I'm using the QPlainTextEdit to display everything.
    For new messages I'm using QPlainTextEdit::appendHtml(const QString & html).
    So far it works great for populating with messages from different parts of the app, like Combat messages for example.

    Now I would like to extend it's functionality but I can't for the life of me figure out a simple solution. There are 2 problems that I would like to solve.

    1. Add a tool tip to specific words.
      For example, in a combat situation, user should be able to hover over text like "[Magicarp] attacked with [splash] doing [0 damage]" and get more information for each bracketed text.
    2. Add clickable text (like an anchor in html) and open different dialog windows depending on different types.
      For Example, text like "You find a [Sword] in a block of stone", user should be able to click, and perform an action or open a dialog on the bracketed text.

    I have been searching online and in the forums for days now, and all I can find is to use QTextBrowser and QTextBlock but just can't make an implementation that works, in any way.

    Is there someone that can offer some guidance? A solution, a helpful link, an alternate idea? Much appreciated, thank you.

    P.S. I'm beginner with Qt framework (1 year) and intermediate with C++(about 4 years self taught)


Log in to reply
 

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