Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to close the Pdf file while closing the application?

How to close the Pdf file while closing the application?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt5python
2 Posts 2 Posters 405 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Selvajothi
    wrote on last edited by
    #1

    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"))
    
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      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
      https://doc.qt.io/qt-5/qtpdf-index.html
      to display the pdf yourself and hence be able to close the pdf view.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved