Write rich text into .odt file
-
Hi,
as for holding/editing the rich text, you might want to think of QTextDocument class. There really is no need to reinvent the wheel, I think. QTextEdit, on the other hand, is perfect as rich text editor, I'd strongly advice to reconsider the UI design in that regard. -
@Tamfub well, in theory you could, of course. Actual implementation would, of course, depend on which bits of functionality from QTextDocument you'd like to copy...
However, since the problem lies within UI, I'd stick to keeping QTextDocument having your data. It would be easier, I think, this way as you can save formatted text directly.
Actual implementation would then rather focus on manipulating the text (insert/edit/delete) and formatting it inside QTextDocument (and there is plethora of classes and methods to help you - all nicely described in the documentation). So you'd have to implement that actual functionality of interacting between whatever UI you have and the data in QTextDocument and not dive into details of saving in the right format. -
Hi,
@Tamfub said in Write rich text into .odt file:
@artwaw
Hi,
Unfortunately there cannot be a textEdit in my project, so I was wondering if I could do the same with the bits that make the QTextDocument and put them inside it.Out of curiosity, can you explain the reasons you can't have a QTextEdit in your UI ?
-
@SGaist
Hello,
the project I am working on is something like this:
https://conclave-team.github.io/conclave-site/
The client and server send data with QTcpSockets. The server side does not have a GUI (it is on the client side, with a textEdit), the client sends each Symbol and the server keeps them in a QList.
Now, we would like to store this Symbols (that compose a rich text) in a local .odt file.
I think it is unconvenient to send the whole textEdit->document() at every change inside the client textEdit. -
@artwaw said in Write rich text into .odt file:
@Tamfub I'd still stick with internal representation as QTextEdit, you can edit it as the symbols flow in.
Agreed, establish a protocol to keep the documents in sync but there's no need to reinvent the wheel.
-
Ok, I have a distributed application and I must apply the CRDT algorithm to keep consistency in shared documents. Since more than one clients may work on the same document (like in Google Docs), how can I keep more than one textEdit graphical element on the server? Maybe I'm not getting it at all.
-
So you want to implement something like Google Docs ?
-
@Tamfub You edit QTextDocument using QTextCursor (it is mentioned in QTextDocument documentation btw.).
Also worth reading before you begin is Rich Text Editing overview page.It is a fair amount of reading but in my honest opinion - it is worth it.