You are not logged in.

soso

Beginner

  • "soso" is female
  • "soso" started this thread

Posts: 26

Location: geneva

  • Send private message

1

Wednesday, June 29th 2005, 3:41pm

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.

zlatko

Professional

  • "zlatko" is male

Posts: 728

Location: Ukraine,Lviv

Occupation: programmer

  • Send private message

2

Wednesday, June 29th 2005, 3:53pm

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 8)

soso

Beginner

  • "soso" is female
  • "soso" started this thread

Posts: 26

Location: geneva

  • Send private message

3

Wednesday, June 29th 2005, 3:54pm

Just the XML itself: xml tags as text

soso

Beginner

  • "soso" is female
  • "soso" started this thread

Posts: 26

Location: geneva

  • Send private message

4

Wednesday, June 29th 2005, 3:59pm

I was trying something like that, but that does not seem to work:

QDomDocument doc( xmlPath );
QString content = doc.toString();
textLabel->setText(content);

zlatko

Professional

  • "zlatko" is male

Posts: 728

Location: Ukraine,Lviv

Occupation: programmer

  • Send private message

5

Wednesday, June 29th 2005, 4:01pm

and where is your problem?
use QFile and QtextEdit
a life without programming its alike empty bottle 8)

zlatko

Professional

  • "zlatko" is male

Posts: 728

Location: Ukraine,Lviv

Occupation: programmer

  • Send private message

6

Wednesday, June 29th 2005, 4:03pm

why you use QDomDocument if you want see your xml as text?
use QFile :)
a life without programming its alike empty bottle 8)

soso

Beginner

  • "soso" is female
  • "soso" started this thread

Posts: 26

Location: geneva

  • Send private message

7

Wednesday, June 29th 2005, 4:06pm

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?

zlatko

Professional

  • "zlatko" is male

Posts: 728

Location: Ukraine,Lviv

Occupation: programmer

  • Send private message

8

Wednesday, June 29th 2005, 4:55pm

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 8)

soso

Beginner

  • "soso" is female
  • "soso" started this thread

Posts: 26

Location: geneva

  • Send private message

9

Wednesday, June 29th 2005, 4:57pm

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..

zlatko

Professional

  • "zlatko" is male

Posts: 728

Location: Ukraine,Lviv

Occupation: programmer

  • Send private message

10

Thursday, June 30th 2005, 8:26am

Source code

1
void QTextEdit::setReadOnly ( bool b ) [virtual slot]
a life without programming its alike empty bottle 8)

soso

Beginner

  • "soso" is female
  • "soso" started this thread

Posts: 26

Location: geneva

  • Send private message

11

Thursday, June 30th 2005, 8:33am

Oki thank you..:)