Adding a QML component to a TextArea



  • Hello, I was wondering if it is possible to add an interactive QML component inside a TextArea QML item? I considered a QTextObject, as it seems that QTextDocument is the underlying object that stores its data, but this seems to only suffice to show static renderings.

    Thanks!


  • Moderators

    Hi,

    Can you explain what do you mean by interactive QML component ?
    Do you want it to be editable ?



  • Hello,
    By interactive, I mean that the qml component can accept mouse events and respond accordingly. I am in the exploratory phase of making an eReader for a book I'm writing. I was hoping to use a TextArea (or something similar) due to its built-in selection, highlighting and HTML parsing capabilities. I was hoping to embed an image/table or figure that the user can interact with, such as displaying an annotation when the mouse hovers over a part of an image/figure/table.

    THanks again!


  • Moderators

    According to your requirements TextArea indeed would be a good candidate for features that you mentioned.
    AFAIK, for the other requirement for "on hover" you can use the "linkHovered":http://qt-project.org/doc/qt-5/qml-qtquick-controls-textarea.html#linkHovered-signal signal provided the image/figure is created as a link and then with its corresponding handler you can load and display the component.
    MouseArea doesn't seem to work with TextArea even with propagateComposedEvents set to true so you are limited to use linkHovered only.


Log in to reply
 

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