'Disable editing QFile
The problem is the following, there are blob files in the DataBase with a various documents in it. It can be .pdf, .txt, .docx, and so on. Further through the following code:
QFile file(qApp->applicationDirPath().append("/file_from_DB." + query.value(1).toString()));
if(file.open(QIODevice::WriteOnly))
{
{
QByteArray ba = query.value(0).toByteArray();
file.write(ba);
file.close();
}
}
else
{
qDebug() << "Error";
}
QDesktopServices::openUrl(qApp->applicationDirPath().append("/file_from_DB." + query.value(1).toString()));
I create a temporary file in the root folder with the program, then open it with QDesktopServices. The problem is that naturally - if the file is edited (suppose it is .docx), then, of course, the updated version is not written to the database. To implement such a thing is too problematic for me and my meager knowledge. Therefore, I left it as it is - but people complain that they intuitively want to edit the file. They do this, close the file - and then find that the file hasn't changed. How can this problem be solved, for example, by prohibiting editing the file? Is it possible somehow to create this file in read-only mode and will this be a solution? You need to somehow prohibit any interaction with the document other than viewing it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
