Yes. Cannot say I am surprised... you never initialise the pointer "matrix", so using it is doomed to fail. Nothing to do with QTextStream though. The matrix is entirely unnecessary for writing this file, so unless you need it for some other purpose...
Other observations (if it didn't crash):
- You open and overwrite the file once for every pixel
- You write the address of the matrix in hexadecimal to the file. This has nothing to do with the data pointed to by that pointer.
- The line "endl(tex)" makes no sense at all.
Bookmarks