QFileDialog- Using getOpenFile
-
@JonB @JonB Any help on how to display only file name instead of displaying file full path using the QFileDialog? Thanks in advance. Below is my code.
def Load_First_Certificate(self): self.fname1, ok = QFileDialog.getOpenFileName(self, "Upload Pdf File", "", "Pdf Files(*.pdf)") if ok: defaultPdf = os.path.split(self.fname1) self.ui.Pdf_lineEdit.setText(self.fname1)
-
@JonB @JonB Any help on how to display only file name instead of displaying file full path using the QFileDialog? Thanks in advance. Below is my code.
def Load_First_Certificate(self): self.fname1, ok = QFileDialog.getOpenFileName(self, "Upload Pdf File", "", "Pdf Files(*.pdf)") if ok: defaultPdf = os.path.split(self.fname1) self.ui.Pdf_lineEdit.setText(self.fname1)
print(QFile(self.fname1).fileName()) print(QFileInfo(self.fname1).fileName())
Your code:
self.fname1, ok = QFileDialog.getOpenFileName(self, "Upload Pdf File", "", "Pdf Files(*.pdf)") if ok:
Where do you get the idea that the second result is any kind of
ok
parameter, and that you should be looking at it for success? -
@JonB @JonB Any help on how to display only file name instead of displaying file full path using the QFileDialog? Thanks in advance. Below is my code.
def Load_First_Certificate(self): self.fname1, ok = QFileDialog.getOpenFileName(self, "Upload Pdf File", "", "Pdf Files(*.pdf)") if ok: defaultPdf = os.path.split(self.fname1) self.ui.Pdf_lineEdit.setText(self.fname1)
-
print(QFile(self.fname1).fileName()) print(QFileInfo(self.fname1).fileName())
Your code:
self.fname1, ok = QFileDialog.getOpenFileName(self, "Upload Pdf File", "", "Pdf Files(*.pdf)") if ok:
Where do you get the idea that the second result is any kind of
ok
parameter, and that you should be looking at it for success? -
@jsulm Thanks it's working! After selecting the pdf file saving to a location in my working directory is the problem now. Any assistance please?
@LT-K101 said in QFileDialog- Using getOpenFile:
Any assistance please?
Please ask a concrete question. What is the concrete problem you're having now?
-
@LT-K101 said in QFileDialog- Using getOpenFile:
Any assistance please?
Please ask a concrete question. What is the concrete problem you're having now?
-
@jsulm I want to save the uploaded file itself to a specific directory not just the filename. Example when the user click on open button to select file , after user select file. The file should be saved in a directory.
@LT-K101 Then do so: https://doc.qt.io/qt-5/qfile.html
-
@LT-K101 Then do so: https://doc.qt.io/qt-5/qfile.html