2017-03-12 8 views
1

QDesktopServices를 사용하여 지정한 파일이나 폴더를 시스템에서 열려고합니다.PyQT | QDesktopServices.openUrl 경로에 공백이있는 경우 작동하지 않습니다.

아래의 코드는 그들에 공백이없는 경로에 대한 완벽한 작동하지만 공백이있는 경로에 대한 출력이 내가 확인한

/home/kerneldev/Documents/Why alcohol doesn't come with nutrition facts.mp4 


gvfs-open: /home/kerneldev/Documents/Why%20alcohol%20doesn't%20come%20with%20nutrition%20facts.mp4: error opening location: Error when getting information for file '/home/kerneldev/Documents/Why%20alcohol%20doesn't%20come%20with%20nutrition%20facts.mp4': No such file or directory 

이다, 그렇지 않은 경우

def openFile(self): 

    print self.oVidPath 
    print "\n" 
    url = QUrl(self.oVidPath) 
    QDesktopServices.openUrl(url) 
    self.Dialog.close() 

및 실행 실패 지정한 경로가 존재합니다.

그렇지 않으면 QUrl 네트워크 URL로 경로를 처리하고 그 상황에서 사용할 수 있도록 인코딩합니다, 당신은 file:// URL을 사용할 필요가

답변

3

제발 도와주세요. 따라서 대신 사용해보십시오.

url = QUrl.fromLocalFile(self.oVidPath)