tags:

views:

119

answers:

1

hi,

i'm having QTextEdit widget with large content in it (content is XML). i want to take the content and set it into a QDomDocument, so i take the content using

document = textEdit->document();

but i dont know how to take it from here into a QDomDocument... what's the best way to do it ?

+1  A: 

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.

liaK
error: 'class QTextEdit' has no member named 'toAscii'
kaycee
oops... its a bit of misunderstanding.. try change textEdit->toPlainText()->toAscii(); I edit my answer too..
liaK
I think you dont have to convert to Byte array at all i.e toAscii().. Try giving xmlDocument->setContent(textEdit->toPlainText(),.. Sorry I couldn't test by myself.. Check and let know..
liaK
toAscii() returns QByteArraywhat results in "no match for call to '(QByteArray) ()'"
kaycee
Why toAscii() ? setContent takes a QString, let Qt do the content encoding conversion.
Harald Scheirich
@ Harald, ya true.. i added in the previous comment..
liaK
liaK