Seeking Qt5 WYSIGWG editor design advice

87 Views Asked by At

I am planning a new desktop application. It will provide a WYSIWYG editor for HL7 files (OSS Project). HL7 is a structured file format often used by hospitals for exchanging data between systems.

The basic structure of the format comprises of records which are \r delimited. A record can have N fields which are | delimited. A field itself can be sub-devided into components ^ and sub-components & and fields can be repeated ~ (similar to an array). Every message type has a different number of fields/components and sub-components. Empty fields at the end of a record can be omitted.

Example of a simple record: OBX|14|NM|0050–5^Calcium||8.9|mg/dl|8.4–10.4||||F

I have already implemented an efficient parser which turns a whole file into a hirarchial data structure in C. I want to implement an application that allows editing these files like in a text editor. I want to keep the underlaying hirarchial datastructure at any point, so it is easy to validate structure and content of every field, upon user changes, quickly.

Also note worthy is, that I already implemented a viewer where the document strcuture is displayed in a QTreeView. The structure is using a QAbstractItemModel.

Now to my actual question: how would I approach the problem of having a text editor with a structured data model in Qt. I have done some research:

  • there is a QDomDocument, it seems to be made to work with xml data. I could convert my structure into XML but can the dom object be used with a text editor ?
  • Is there a way to bind a tree like document model to QTextEdit or QPlainTextEdit?
  • is it possible to bind a QAbstractItemModel to a document in QTextEdit or QPlainTextEdit?

What would be the best approach to tackle the problem of having a textual representation of a tree that gets updated once text and/or stricture is changed by editing in the text field?

Performance and cross platform capability is important, so this project will be implemented in C++.

Thanks for any advice and examples appreciated if you have any.

-S

0

There are 0 best solutions below