Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to close the Pdf file while closing the application?
Selvajothi last edited by
I have a pyqt5 application in which I have opened a pdf now when the user exits the application pdf should also close.
I have tried the following
destinationTemp = QDir.fromNativeSeparators(path) if os.path.exists(destinationTemp + fileName + ".pdf"): os.remove(destinationTemp + fileName + ".pdf") QFile.copy(":/newPrefix/sample.pdf", destinationTemp + fileName + ".pdf") QDesktopServices.openUrl(QUrl.fromLocalFile(" destinationTemp + fileName + ".pdf"))
Well you ask the OS to open any app that is tied to the extension pdf.
Its not really possible to ask it to close without using platform native api calls
to find this window and try to close it.
You could use
to display the pdf yourself and hence be able to close the pdf view.