PDA

View Full Version : Structuring a document with QTextFrame



Pap57
7th July 2018, 07:35
Hello,
I want to have a editor for a kind of specific structured document. I'm start from the textedit example.
I hope to create QTextFrame to represent some sections.
But I didn't find any way to do that.
In fact I find no way to create QTextFrame outside the previous one. Each new Frame I create with insertFrame to QTextCursor is inside the previous one, even if I place the cursur with atEnd or atStart
I use Python3 and Qt5, but don"t think that Python is different for this matter.

Pap57
9th July 2018, 14:15
Hello,
I found the solution.
I have first to get the root frame:

rootframe = mytextEdit.document().rootFrame()
then to place the cursor at end:

cursor = rootframe.lastCursorPosition()
and I can now insert a new frame:

cursor.insertFrame(frameFormat)
Of course frameFormat is set before.

Found in http://doc.qt.io/qt-5/richtext-cursor.html