当前位置: 代码迷 >> python >> 如何在pyQt中调整QFileDialog的大小?
  详细解决方案

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

热度:74   发布时间:2023-06-13 13:42:14.0

这是我关于显示 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。
然而我不知道该怎么做。
希望有谁能解决这个问题。

我认为唯一的选择是不使用便利函数getOpenFileName 您需要自己创建对话框并连接其信号。

像这样的东西:

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

def showDialog(self):
    filedialog = QtGui.QFileDialog()
    filedialog.fileSelected.connect(self.fileSelected)
    filedialog.setFixedSize(320,240)
    filedialog.show()
  相关解决方案