Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Is there a way to draw geometric shapes below the text in a QTextDocument?
jeanmilost last edited by
I need to create a text document, which should be both drawn in a view on the user interface and printed, especially to a PDF file.
About the text itself, I know how to perform all I need to do. I know how to align my text, create paragraphs, insert images, set the font, manipulate the layouts, ...
But an important point is missing to achieve my text document: I need to draw geometrical shapes in the background of several paragraphs, e.g a rounded rectangle.
On the user interface I may access to a QPainter to workaround that. However I need the exact same rendering on the user interface and on the printed document. And using the same workaround during the print process will force me to write my own function, which is a painful way and misses the opportunity to use the print() function provided by the QTextDocument class, which already provides all I need, like page cutting.
On the other hand, I tried to add such background shapes by writing a css code, however a such feature seems to be out of the scope of the limited css supported by Qt.
So is there a way to add geometrical shapes (e.g rectangles, circles, ellipses, paths, ...) in a QTextDocument, and if yes, how to achieve that?