Dear visitor, welcome to QtForum.org.
If this is your first visit here, please read the Help. It explains in detail how this page works.
To use all features of this page, you should consider registering.
Please use the registration form, to register here or read more information about the registration process.
If you are already registered, please login here.
preview content
Hello,
I have other troubles again.. I would like that the user choose a XML file and this file to be displayed in my dialog in a textEdit or textLabel for example. What is the easiest way to obtain that? Am I forced to use a class preview etc..?
S.
what do you want see after that?
result of parsing xml or just xml tags as text?
a life without programming its alike empty bottle
Just the XML itself: xml tags as text
I was trying something like that, but that does not seem to work:
QDomDocument doc( xmlPath );
QString content = doc.toString();
textLabel->setText(content);
and where is your problem?
use QFile and QtextEdit
a life without programming its alike empty bottle
why you use QDomDocument if you want see your xml as text?
use QFile
a life without programming its alike empty bottle
I was thinking that with QDomDocument I could get the entire text directly but my variable content is empty. Is there a function that get all the text in a qstring with qfile?
When I do QDomDocument doc( xmlPath ); I should have the path of my xml with its name right?
|
Source code
|
1
2
3
4
5
6
|
QFile file( "file.txt" );
if ( file.open( IO_ReadOnly ) )
{
QTextStream stream( &file );
txtEdit.append( strem.read() );
}
|
this should be work
a life without programming its alike empty bottle
It's oki I found. Thank you.
I just need now to find how to make the content of the textedit not enabled but that the user can use the scroll bar to go down in the XML..
|
Source code
|
1
|
void QTextEdit::setReadOnly ( bool b ) [virtual slot]
|
a life without programming its alike empty bottle
Oki thank you..