Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, December 2006
Writing to a file


Message 1 in thread

I am trying to write the info stored in a variable to a file.  How do I
get Qt to write the value stored in the variable instead of the memory
address of the variable to the file?
 
Thanks,
Roger

Message 2 in thread

Housman, Roger W. schrieb:
> 
> I am trying to write the info stored in a variable to a file.  How do I
> get Qt to write the value stored in the variable instead of the memory
> address of the variable to the file?

Does that work:

  int   value = 42;
  QFile file ("c:\\temp\\test.txt");

  if (file.open (QIODevice::WriteOnly | QIODevice::Text) == true) {
    QTextStream out (&file);
    out << "My value: " << value << "\n";
    file.close();
  }

Cheers, Oliver

--
 [ signature omitted ] 

Message 3 in thread

Make sure you dereference your variable.  Your probably sending the
address to the stream, rather then the value.


Scott

 

________________________________

From: Housman, Roger W. [mailto:housmanrw@xxxxxxxx] 
Sent: Thursday, December 28, 2006 7:02 AM
To: qt-interest@xxxxxxxxxxxxx
Subject: Writing to a file

 

I am trying to write the info stored in a variable to a file.  How do I
get Qt to write the value stored in the variable instead of the memory
address of the variable to the file?

 

Thanks,

Roger