更新时间:2022-04-28 08:24:31
您只能使用registerField()
方法将qproperty传递给QWidget
,在QFileDialog
的情况下,这是不可能的,因为没有与选择相关联的q属性也是getOpenFileName()
的静态方法,获取对象是一项复杂的任务,有两种可能的解决方案,第一种是创建一个从QFileDialog
继承并具有与qcproperty相关联的qproperty的类.选择或使用python的魔术来传递值.最后一个是我将使用的方法.
You can only use registerField()
method to pass a qproperty to the QWidget
, in the case of QFileDialog
it is not possible since there is no q-property associated with the selection also getOpenFileName()
is a static method and getting the object is a complicated task, There are 2 possible solutions, the first is to create a class that inherits from QFileDialog
and has a qproperty associated with the selection or use the magic of python to pass the values. The last one is the method I will use.:
class ExecutePage(QtWidgets.QWizardPage):
...
def get_file_name(self):
name, _ = QtWidgets.QFileDialog.getOpenFileName(self.uploader,'Choose File to Run')
self.wizard().file_name = name
class ConclusionPage(QtWidgets.QWizardPage):
...
def initializePage(self):
if hasattr(self.wizard(), 'file_name'):
self.setSubTitle(self.wizard().file_name)