PySide QFileDialog 窗口大小 [英] PySide QFileDialog window size

查看:85
本文介绍了PySide QFileDialog 窗口大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,小部件窗口大小可以通过调用setGeometry"函数来定义.

As far as I understand widget window size could be defined by calling 'setGeometry' function.

import_dialog = QtGui.QFileDialog()
import_dialog.setWindowTitle('Import File')
import_dialog.setDirectory(FILE_DIR)
import_dialog.setGeometry(100, 100, 200, 200)
import_file, _ = import_dialog.getOpenFileNames()
print(import_file)

但是当我执行这部分 gui 代码时,我面临着覆盖整个屏幕的弹出窗口.我试图通过调用setGeometry"函数来缩小它,但没有结果.

But when I'm executing this part of my gui code, I'm facing pop up window that covers entire screen. I tried to make it smaller by calling 'setGeometry' function but with no results.

如何让它看起来更小?

谢谢

推荐答案

getOpenFileNamesQFileDialog 类的一个方便的静态方法.它应该处理创建对话框,设置适合您的操作系统的正确大小,并检索结果.试着这样称呼它:

getOpenFileNames is a convenience static method of the QFileDialog class. It should handle creating the dialog, setting the right size as appropriate for your OS, and retrieving the result. Try calling it like this:

filenames, _ = QFileDialog.getOpenFileNames(parent, "Select file", FILE_DIR)

如果这没有帮助,您可以自己创建对话框(就像您所做的那样)并调用 show(),更改大小,然后将 fileSelected 信号绑定到一个插槽.

If that does not help, you can create the dialog yourself (as you did) and call show(), change the size, and bind the fileSelected signal to a slot.

这篇关于PySide QFileDialog 窗口大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆