Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Read/Write WYSIWYG RichText Editor with QML

Read/Write WYSIWYG RichText Editor with QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 415 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    elle
    wrote on last edited by
    #1

    having read and tried out the Qt Quick TextEditor example, I am trying to understand what the best practices are, when trying to write a QML-Based application that changes the underlying TextDocument of a TextEdit (the QML one).

    Specifically the modifications that are being done through the C++ TextCursor interface e.g. in:

    void DocumentHandler::mergeFormatOnWordOrSelection(const QTextCharFormat &format)
    {
        QTextCursor cursor = textCursor();
        if (!cursor.hasSelection())
            cursor.select(QTextCursor::WordUnderCursor);
        cursor.mergeCharFormat(format);
    }
    

    seem to contradict the API documentation of QQuickTextDocument, explicitly stating:

    Warning: The QTextDocument provided is used internally by Qt Quick elements to provide text manipulation primitives. You are not allowed to perform any modification of the internal state of the QTextDocument. If you do, the element in question may stop functioning or crash.

    https://doc.qt.io/qt-5/qquicktextdocument.html

    The changes performed by user interaction (toggling bold, italic, specifying a link) all change the internal state of the QTextDocument, at least the produce or remove new QTextFragments.

    Is a change in formatting not considered a modification of the internal state?

    Apart from that, I only found examples of read and write Text Editor based on a QtQuick-UI that do manually string replacements to add HTML around the current selection. Is this really the way to go?

    Maybe this is just me being too cautious before continuing where the Text Editor C++ example stops...

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved