Yes, it is possible. There is one thing to keep in mind though. By default the qt resource compiler rcc compresses the resources.
The file.size() call will return the actual, un-compressed size of the original file. However, the embedded resource is compressed and is most likely a different size. The file.map(0, file.size()) returns an error since the size passed to map() is larger than the resource being mapped. Even if you pass the correct size to map(), or a smaller size, the memory will contain the compressed data, not the un-compressed data.
The solution is to not compress the embedded resource. This can be accomplished by adding:
QMAKE_RESOURCE_FLAGS += -no-compress
to your qt project file. See here for explanation of QMAKE_RESOURCE_FLAGS.