Thanks to mugiseyebrows's answer, I solved the problem like so. Instead of a file, I set a registry key.
Following code goes at the end of InnoSetup ISS file:
[Code]
function InitializeSetup(): Boolean;
begin
RegWriteStringValue(HKEY_CURRENT_USER, 'SOFTWARE\SoftwareName\Settings', 'warn_on_exit', 'false');
Result := True;
end;
procedure DeinitializeSetup();
begin
RegWriteStringValue(HKEY_CURRENT_USER, 'SOFTWARE\SoftwareName\Settings', 'warn_on_exit', 'true');
end;
Following is the closeEvent() code in Qt:
QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\SoftwareName\\Settings", QSettings::Registry32Format);
void MainWindow::closeEvent(QCloseEvent *ev){
if(settings.value("warn_on_exit",true).toBool())){
QMessageBox qmb(this);
qmb.setIcon(QMessageBox::Question);
qmb.setWindowTitle("");
qmb.setText("Are you sure you want to exit?");
qmb.addButton("Yes",QMessageBox::YesRole);
qmb.addButton("No",QMessageBox::NoRole);
qmb.exec();
if(qmb.clickedButton()->text()=="No"){
ev->ignore();
return;
}
QMainWindow::closeEvent(ev);
}