PyQt custom dialog return value after buttonBox click

Monday, October 20, 2014

Task: Open a custom diaglog to let user input necessary info. After "OK" buttonBox clicked, return values to current GUI

1. First you have to built for custom dialog with QtCreater
2. In your GUI, write the following code
from Inputfiles_Dialog import Inputfiles_Dialog
#Inputfiles_Dialog is the ui created by QtCreater
d = Inputfiles_Dialog(self.iface)
d.show()
if d.exec_():
    self.Inputfiles_set = d.getInputs()

3. In your custom dialg,connect your buttonBox:
self.connect(self.OK_buttonBox, SIGNAL("accepted()"),self.ProcessInfo)
.
.
.
def ProcessInfo(self):
    #do somthing
.
.
.
    self.accept()
4. In your custom dialg, add a function to return values:
def getInputs(self):
    return usefulinfo