问题
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