如何在pyQt中调整QFileDialog的大小?

时间:2015-10-17 17:11:12

标签: python pyqt

以下是关于展示QFileDialog的代码的一部分。

expand='Image Files(*.mp3 *.wav)'
tips=u'choose the music file'
path = QtGui.QFileDialog.getOpenFileName(self, tips, QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.MusicLocation), expand)

然后它可以显示选择文件的窗口 但它的尺寸对我来说太大了 我想设置尺寸为320 * 240 但是,我不知道该怎么做 希望有人能解决这个问题。

1 个答案:

答案 0 :(得分:1)

我认为唯一的选择是不使用便利功能getOpenFileName。 您需要自己创建Dialog并连接其信号。

这样的事情:

def fileSelected(self, filename):
    print(filename)

def showDialog(self):
    filedialog = QtGui.QFileDialog()
    filedialog.fileSelected.connect(self.fileSelected)
    filedialog.setFixedSize(320,240)
    filedialog.show()