The solution to the crash after calling the file dialog QFileDialog in PyQt5

The solution to the crash of PyQt5 file dialog after QFileDialog is called

# Description of the problem
under PyQt5 5.15 version, open Qtdesigner.exe in the main interface in Win10 normal, but if you open the folder selected file will cause the program to exit stop python, which should probably be one bug 5.15 version 5.14.2 there is no . The corresponding call file dialog QFileDialog also has similar problems.

# Solution
1, PyQt5 version rotation == "5.14.2

pip uninstall PyQt5 PyQt5-tools
pip install PyQt5==5.14.2 PyQt5-tools=5.14.2.1.7

2. Mark when calling the file dialog QFileDialog:
QFileDialog.DontUseNativeDialog

def get_datafile(self):
        filename, filetype = QFileDialog.getOpenFileName(self, '選擇數據文件', 'F:\\', "Vertex file(*.txt *.ver)",None,QFileDialog.DontUseNativeDialog)
        self.__filename = filename
        print(filename, filetype)
        # show the selected file in FileName Text
        self.Filename.setText(filename)

Please see the analysis on Stackflow for the reason: QFileDialog crash
Reason description 3. Other problems have been found
PS: Calling the file dialog QFileDialog under Pycharmm+PyQt5 is no problem
Selecting the installed 32-bit Python interpreter is no problem. . .

Guess you like

Origin blog.csdn.net/VerTicalVerTical/article/details/107070503