I currently have a C ++ class inheriting from QQuickPaintedItem . I use it to draw mock-up, paginated rich text with QTextDocument via QTextDocument::drawContents (or by directly calling the QTextDocumenLayout draw method).
However, as stated in the QQuickPaintedItems documentation, there are thread issues that you need to know:
Warning When creating QObjects, emitting signals, triggering timers, and similar functions inside this function, special care must be taken, since they will have an affinity for the rendering stream.
In particular, in this case, QTextDocumentLayoutPrivate has timers that start / stop when QTextDocumenLayout::draw called. Unfortunately, QTextDocument and, therefore, timers live in the main qml stream, and paint is called in the rendering stream, which leads to messages like
QBasicTimer :: start: Timers cannot be started from another thread
Although this does not affect the functionality of my application (for now), it is probably not very good.
So my question is is there a better way to show broken text in QML (not necessarily including QQuickPaintedItem ).
source share