The problem of the save functionality came from the fact that the QString::right() method expects the number of characters it should take from the end of the string forward. The lastIndexOf() method finds the last occurence of a character but returns the index from the beginning of the string.
Now instead of counting length of "filename+extension" from the end, the right function counted the number of characters from the end, resulting in an invalid path in the save method.
To reduce errors in this area I replaced the QString methods with the QFileInfo methods that take care of these things and is therefore more safe.
The problem of the save functionality came from the fact that the QString::right() method expects the number of characters it should take from the end of the string forward. The lastIndexOf() method finds the last occurence of a character but returns the index from the beginning of the string. Now instead of counting length of "filename+extension" from the end, the right function counted the number of characters from the end, resulting in an invalid path in the save method. To reduce errors in this area I replaced the QString methods with the QFileInfo methods that take care of these things and is therefore more safe.