How to serialize and deserialize rich text in QTextEdit?

后端 未结 3 1265
面向向阳花
面向向阳花 2020-12-21 05:40

Say I have a structure like this:

class AAA
{
    BBB      bb_member;
    double   dbl_member;
    ....................
}

class BBB
{
    int             in         


        
3条回答
  •  一生所求
    2020-12-21 06:02

    QTextEdit is a widget, and it doesnt make much sense to write a widget to a file, but we can write the content of the widget (QTextEdit::toHtml()) to the file. When reading from file, we can create a new widget object and initialize it with the contents of the file (QTextEdit::setHtml()).

    I must add that it would probably be a better design to store just the richtext data in BBB (as a html QString) as opposed to the QTextEdit itself.

提交回复
热议问题