Qt + QTextEdit content into QDomDocument

假装没事ソ 提交于 2019-12-11 11:39:15

问题


I'm having QTextEdit widget with large (XML) content in it, so I take the content using:

document = textEdit->document();

How do I set it into a QDomDocument?


回答1:


Try this...

QDomDocument *xmlDocument = new QDomDocument();
QString error;
int errorLine = 0;
int errorColumn = 0;
bool docStatus = xmlDocument->setContent(textEdit->toPlainText()->toAscii(),&error,&errorLine,&errorColumn);

It isn't tested. But hope it will work.. Check it out..

Edit: Alternatively give

bool docStatus = xmlDocument->setContent(textEdit->toPlainText(),&error,&errorLine,&errorColumn);

This is a better one when compared to the previous.



来源:https://stackoverflow.com/questions/2938424/qt-qtextedit-content-into-qdomdocument

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!