Adding QByteArray::Base64UrlEncoding to the args of imgData.toBase64() will add better compatibility when sending it over to something like PHP or JS. Essentially, it replaces all spaces with - . You could also do QByteArray::Base64Encoding which will replace all spaces with + instead of -. However, the - tends to work better amongst other things.
Either one is better than nothing.