qfiledialog

PyQt5 QFileDialog closes when filename clicked

冷暖自知 提交于 2021-02-11 14:24:02
问题 I am using PyQt5 QFileDialog.getOpenFileName . I am expecting the box to remain open until the "open" button is clicked. However, when I run the code on my Linux system, the dialog box closes immediately when the file name is clicked. On a Windows system, the box behaves as expected and remains open until the 'Open' button is clicked. The results are the same with or without the QFileDialog.DontUseNativeDialog option set. from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton,

PyQt5 - how to bring the Qfiledialog to the front?

余生长醉 提交于 2021-02-10 20:15:57
问题 My code uses PyQt to open up a folder select dialog. Once a folder is selected it is minimized. I'd like for the dialog to pop up in front of any other windows. I haven't been able to find a solution yet. Any suggestions? from sys import executable, argv from subprocess import check_output from PyQt5.QtWidgets import QFileDialog, QApplication def gui_fname(directory=''): file = check_output([executable, __file__, directory]) return file.strip() if __name__ == "__main__": directory = argv[1]

How to create a file dialog that returns file paths for both selected files AND directories?

守給你的承諾、 提交于 2021-02-08 06:34:24
问题 I'm trying to use QFileDialog to get a list of the paths of selected folders AND directories. I know how to do one or the other using QFileDialog.getOpenFileNames and QFileDialog.getExistingDirectory , but not both at the same time. The C++ docs and other questions elsewhere didn't seem to help me no matter how much I googled. I am using PyQt5 5.14.2 and Python 3.8.2 on Windows. Edit: I've managed to conjure up the following solution not using the native Windows dialog and it works but seems

Qt QFileDialog - native dialogs only with static functions?

二次信任 提交于 2021-02-07 13:16:52
问题 I'm trying to simply save a file. However, I need a filename entered without a suffix to automatically get a default suffix (which setDefaultSuffix() does). I'd rather not completely lose the native save dialog just for this. exec() is not overloaded from QDialog, so it totally bypasses the native hook (ignoring the DontUseNativeDialog option even if it's false). If I disable the file overwrite warning and append the default suffix myself after the function returns, then I'd be re-opening the

Qt QFileDialog - native dialogs only with static functions?

不想你离开。 提交于 2021-02-07 13:15:56
问题 I'm trying to simply save a file. However, I need a filename entered without a suffix to automatically get a default suffix (which setDefaultSuffix() does). I'd rather not completely lose the native save dialog just for this. exec() is not overloaded from QDialog, so it totally bypasses the native hook (ignoring the DontUseNativeDialog option even if it's false). If I disable the file overwrite warning and append the default suffix myself after the function returns, then I'd be re-opening the

QFileDialog with virtual keyboard

别说谁变了你拦得住时间么 提交于 2021-01-29 12:20:52
问题 Is there a way to detect when the filename text edit gets focus? I need to display a virtual keyboard when the text edit is entered Thanks 回答1: That's not an exact solution, but here's a rather hacky way, leading to it, should work -- QFileDialog is also a widget, with children, so you can get access to that filename QLineEdit and do whatever needed with it. Something like... QLineEdit* lineEdit = dlg->findChild<QLineEdit*>(); Message filter would be better, because it would not require

How to control a QFileDialog using Qt Test?

久未见 提交于 2021-01-29 04:21:38
问题 I have 2 questions: How can I access a QFileDialog and write the path of a file in the "File name" field using the Qt Test module? I am asking that because I am developing some GUI tests in Qt and now I need to open a text file. The following code creates the QFileDialog and gets the file path: QString filePath = QFileDialog::getOpenFileName( this, "Open", "", tr("Text Files (*.txt)") ); If I am using a thread ( QThread ) to load the content in this text file, how can I wait for this thread

code crash after opening a QfileDialog in a QThread

左心房为你撑大大i 提交于 2020-12-12 06:27:34
问题 I wrote a code who display in a GUI, the steps of calcul of an algorithm. For this, i use a QThread which is in charge to check the steps and display it in a GUI. This alone is working. However, the first step for the user is to select a configuration file with a QFileDialog. And at this level, Python code crashes after the openning of the QFileDialog if a file is not selected after several seconds. The crash occures when the mouse goes over the QFileDialog window openned. I quite new with

code crash after opening a QfileDialog in a QThread

孤街浪徒 提交于 2020-12-12 06:26:28
问题 I wrote a code who display in a GUI, the steps of calcul of an algorithm. For this, i use a QThread which is in charge to check the steps and display it in a GUI. This alone is working. However, the first step for the user is to select a configuration file with a QFileDialog. And at this level, Python code crashes after the openning of the QFileDialog if a file is not selected after several seconds. The crash occures when the mouse goes over the QFileDialog window openned. I quite new with