QSharedMemory::data method returns a void*, so it's just a pointer to a bytes array, where you can place anything as you like. Copying integer types is even easier.
qint64 yourQInt64 = ...;
qint64* placeToWriteQInt64 = (qint64*)sharedMemory.data();
*placeToWriteQInt64 = yourQInt64;
qint64 yourQInt64 = ...;
qint64* placeToWriteQInt64 = (qint64*)sharedMemory.data();
*placeToWriteQInt64 = yourQInt64;
To copy to clipboard, switch view to plain text mode
Btw., do not use this code:
allplayercount = (qint64)(numofallplayers.data());
allplayercount = (qint64)(numofallplayers.data());
To copy to clipboard, switch view to plain text mode
This way you write a void*, the pure address, to a qint64, not a value stored in that place in a memory.
Use rather this:
qint64 allplayercount = *((qint64*)numofallplayers.data());
qint64 allplayercount = *((qint64*)numofallplayers.data());
To copy to clipboard, switch view to plain text mode
Bookmarks