PySide QFileDialog window size

末鹿安然 提交于 2019-12-11 17:03:55

问题


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)

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.

How can I make it to appear smaller?

Thanks


回答1:


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)

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.



来源:https://stackoverflow.com/questions/25890938/pyside-qfiledialog-window-size

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!