Python Forum
[PyQt] PyQT5: Open QFiledialog in a Dialog which was create in qt designer
Thread Rating:
  • 2 Vote(s) - 1.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] PyQT5: Open QFiledialog in a Dialog which was create in qt designer
#1
I create a dilaog in Qt Designer and I use PyQT5. After a selcetion of users and the ouput format, I will open a Filedialog to chouse the Filename and the path. But the problem is, that the Dilaog is inherit by object and the Filedialog need in the first parameter a QWidget

My CreateReportDialog:

[code]from PyQt5 import QtCore, QtGui, QtWidgets
from Database.DatabaseOperations import *
from rebezcheck_main import *

class CreateReport_Dialog(object):

    def __init__(self):
        self.ownerId = None
        self.firmId = None
        self.format = None


    def setupUi(self, createreport):
        createreport.setObjectName("Dialog")
        createreport.resize(400, 300)
....
    def createReport(self):
        msgbx = DataChangeMsgBx()
        check_input_list = self.check_input()
        if len(check_input_list) > 0:
            error_strg = "\n".join(check_input_list)
            msgbx.checkInputsMsgBx(error_strg)
        else:
            fileName = QFileDialog.getSaveFileName(self, 'Dialog Title', '/path/to/default/directory', selectedFilter='*.txt') # Error_Message
            if fileName:
                print("filename")[/code]
If I ty to open this Dialog I get the errormessage:

[inline][
TypeError: getSaveFileName(parent: QWidget = None, caption: str = '', directory: str = '', filter: str = '', initialFilter: str = '', options: Union[QFileDialog.Options, QFileDialog.Option] = 0): argument 1 has unexpected type 'CreateReport_Dialog'
/inline]

The function in my mainwindow to Open this dialog:

def showCreateReportDialog(self):
       createReportDialog = QtWidgets.QDialog()
       ui = CreateReport_Dialog()
       ui.setupUi(createReportDialog)
       createReportDialog.exec_()
I understand the problem but I don't know how I can fix them

Greets niesel
Reply


Messages In This Thread
PyQT5: Open QFiledialog in a Dialog which was create in qt designer - by nieselfriem - Apr-29-2017, 01:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  QT Designer Krissstian 4 1,816 May-26-2022, 09:45 AM
Last Post: Krissstian
  Qt Designer : help document viewer error. davediamond 2 1,657 Apr-14-2022, 10:38 AM
Last Post: davediamond
  GUI programming PyQt 5 + Qt Designer flash77 9 2,878 Mar-19-2022, 10:31 AM
Last Post: flash77
  How a QMainWindow can open a dialog? panoss 4 3,694 Feb-03-2022, 04:33 PM
Last Post: panoss
  How can I create a new tag with PyQt5? nickzsche 2 1,540 Jan-12-2022, 06:10 PM
Last Post: Axel_Erfurt
  [PyQt] QT5 Designer Drawing greenhorn1 1 2,634 Dec-30-2021, 05:12 PM
Last Post: deanhystad
  [Tkinter] question for a tkinter dialog box RobertAlvarez424 2 2,331 Aug-25-2021, 03:08 PM
Last Post: RobertAlvarez424
  [Tkinter] cancelling open dialog gives empty string rwahdan 2 3,487 Jul-17-2021, 09:17 PM
Last Post: steve_shambles
  Installed Designer - Helpf Files for "assistant" are missing Valmont 0 2,047 Mar-22-2021, 11:09 AM
Last Post: Valmont
  Using a GUI Designer vs. hard coding 357mag 9 6,242 Feb-21-2021, 06:43 PM
Last Post: kkaur

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020