
Originally Posted by
mclark
I've also tried the integer casting but have not been able to make that work.
Something like this should work:
Q_ASSERT( sizeof( quint32 ) == sizeof( void * ) );
stream << reinterpret_cast< quint32 >( ptr );
...
quint32 v;
stream >> v;
ptr = reinterpret_cast< void * >( v );
Q_ASSERT( sizeof( quint32 ) == sizeof( void * ) );
stream << reinterpret_cast< quint32 >( ptr );
...
quint32 v;
stream >> v;
ptr = reinterpret_cast< void * >( v );
To copy to clipboard, switch view to plain text mode
(if you have 64-bit system, you should use quint64).

Originally Posted by
mclark
Is there another stream class that would be better suited for handling both text and data?
You can try QDataStream.
Bookmarks