[Qt-interest] QT Console application QTextStream stdout access violation
Louis Hoefler
louis.hoefler at gmx.de
Fri Nov 5 22:31:06 CET 2010
No, I already tried this. It does not work.
Thank you, Louis
Vladimir Barbarosh <vladimir.barbarosh at gmail.com>
at Fri, 5 Nov 2010 23:26:33 +0200
>> Hello everyone.
>>
>> I try to create a simple console application with Visual C++ 2010 and QT
>> 4.7.0.
>>
>> I try to use the QTextStream class to write to the stdout stream.
>> Howevery, if the code
>>
>> #include<QTCore>
>> int main(int argc, char** argv) {
>> QTextStream out(stdout, QIODevice::WriteOnly);
>> return 0;
>> }
>>
>> is executed, the application crashes on the 4th line with:
>>
>> Unhandled exception at 0x77b08c19 in console.exe: 0xC0000005: Access
>> violation writing location 0x00000014.
>>
>> Does someone know what causes this problem?
> On my Debian machine your code works fine (except warnings about unused
> parameters).
>
> Try to add the following line at the very begining of main() function:
>
> QCoreApplication app(argc, argv);
>
> Or just try this code:
>
> #include<QtCore>
>
> int
> main(int argc, char **argv)
> {
> QCoreApplication app(argc, argv);
> QTextStream out(stdout, QIODevice::WriteOnly);
> out<< "Hello world\n";
> return 0;
> }
>
> Does it works?
>
More information about the Qt-interest-old
mailing list