问题描述
这是我关于显示 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楼
我认为唯一的选择是不使用便利函数getOpenFileName
。
您需要自己创建对话框并连接其信号。
像这样的东西:
def fileSelected(self, filename):
print(filename)
def showDialog(self):
filedialog = QtGui.QFileDialog()
filedialog.fileSelected.connect(self.fileSelected)
filedialog.setFixedSize(320,240)
filedialog.show()