如何在 pyQt 中调整 QFileDialog 的大小?
How to adjust the QFileDialog's size in 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)
然后会显示window选择文件。
但是它的尺寸对我来说太大了。
我要设置的尺寸是320*240.
但是我不知道怎么办。
希望有人能解决这个问题。
我认为唯一的选择就是不使用便捷功能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()
这是我关于显示 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)
然后会显示window选择文件。
但是它的尺寸对我来说太大了。
我要设置的尺寸是320*240.
但是我不知道怎么办。
希望有人能解决这个问题。
我认为唯一的选择就是不使用便捷功能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()