You are not logged in.

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.

1

Wednesday, May 5th 2004, 9:23am

Problem with QString and frpintf

Hello,
i would like to write in a file the content of a Qstring, so i proceed ke this

fprintf(file,"%s\n",my_Qstring);

Its doesn't work, (the app crashes) and i've got this warning :
cdplayerwindow.cpp:991: warning: cannot pass objects of non-POD type `class QString' through `...'; call will abort at runtime

does anyone got a idea ?

thanks
Punx120
Sorry for bad english

br06

Trainee

  • "br06" is male

Posts: 121

Location: Germany

Occupation: surveying engineer

  • Send private message

2

Wednesday, May 5th 2004, 9:38am

RE: Problem with QString and frpintf

Hi,

it's more efficiet to use the Qt IO-classes, instead of good old C fprintf().
If you have to use fprintf, you can write my_QString.ascii()

Christian

3

Wednesday, May 5th 2004, 1:23pm

Thanks a lot. This class is very useful actually.

cheers.
Punx120
Sorry for bad english

Posts: 2,162

Location: Graz, Austria

Occupation: Student

  • Send private message

4

Wednesday, May 5th 2004, 4:52pm

ascii() if the QString only contains 7 bit ASCII.
latin() if it might contain characters from Latin1 set

local8Bit() if you think it might contain characters of the users locale.

Maybe using QTextStream and QFile would be even better :)

Cheers,
_
Qt/KDE Developer
Debian User