Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Closing Modal Window in QT
#1
Hello,

 I create a modal dialog in PyQT5 in this way:

from PyQt5 import QtCore, QtGui, QtWidgets

class FirmUi_Dialog(object):


   def setupUi(self, Dialog):
       Dialog.setObjectName("Dialog")
       Dialog.setWindowModality(QtCore.Qt.ApplicationModal)
       Dialog.resize(311, 300)
       Dialog.setModal(True)
       self.groupBox = QtWidgets.QGroupBox(Dialog)
....
       self.saveFirmPB = QtWidgets.QPushButton(Dialog)
       self.saveFirmPB.setGeometry(QtCore.QRect(140, 240, 75, 23))
       self.saveFirmPB.setObjectName("saveFirmPB")
       self.cancelPB = QtWidgets.QPushButton(Dialog)
       self.cancelPB.setGeometry(QtCore.QRect(220, 240, 75, 23))
       self.cancelPB.setObjectName("cancelPB")
       self.saveFirmPB.clicked.connect(self.saveFirmToDB)
       self.cancelPB.clicked.connect(self.closeFirmDialog)

       self.retranslateUi(Dialog)

   def saveFirmToDB(self):
      print("Save")

   def closeFirmDialog(self):
      pass  #How I can close the Dialog (Modal Window)
            self.close() #doesn't work 
to open the dialog in the Mainwindow, I create the following function:

def showFirmaDialog(self):
   firmDialog = QtWidgets.QDialog()
   ui = FirmUi_Dialog()
   ui.setupUi(firmDialog)
   firmDialog.exec_()
This steps works fine. But I dont' find a way to trigger the close event for this dialog when I push the cancelPB 

Greetings 

niesel
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  How to stop a tkinter function, without closing the window? keakins 5 50 2 hours ago
Last Post: keakins
  update a variable in parent window after closing its toplevel window gray 5 322 Mar-20-2017, 10:35 PM
Last Post: Larz60+
  GTK main window calling a main window DennisT 4 661 Oct-19-2016, 09:36 PM
Last Post: DennisT

Forum Jump:


Users browsing this thread: 1 Guest(s)