QFileDialog close my application
-
Hello,
I add to my program a QFileDialog window. When I close the file dialog window, the function keep executing the following command but at the end of the function the main window is closed and after the FileDialog.
Here is my program:
class Controller(QtWidgets.QWidget): view: View model: Model def __init__(self, model: Model, view: View): super(Controller, self).__init__() def open_datalog_folder(self, txt): print(txt) file_dialog = QFileDialog() try: directory = file_dialog.getOpenFileName(None, "Select directory") # file_dialog.blockSignals(True) print ('here') except: print("fzz") passWhen I execute the program, I get the "Here" flag and the the program close. I try to block the signal from my file dialog quit event to avoid to send it to the lain window but it does work.
-
Hello,
I add to my program a QFileDialog window. When I close the file dialog window, the function keep executing the following command but at the end of the function the main window is closed and after the FileDialog.
Here is my program:
class Controller(QtWidgets.QWidget): view: View model: Model def __init__(self, model: Model, view: View): super(Controller, self).__init__() def open_datalog_folder(self, txt): print(txt) file_dialog = QFileDialog() try: directory = file_dialog.getOpenFileName(None, "Select directory") # file_dialog.blockSignals(True) print ('here') except: print("fzz") passWhen I execute the program, I get the "Here" flag and the the program close. I try to block the signal from my file dialog quit event to avoid to send it to the lain window but it does work.
@Xav12358 said in QFileDialog close my application:
getOpenFileName
This is a static method: there is no need to create a QFileDialog instance to call it.
-
@Xav12358 said in QFileDialog close my application:
getOpenFileName
This is a static method: there is no need to create a QFileDialog instance to call it.
-
@jsulm said in QFileDialog close my application:
QFileDialog
Than you for the tips. Indeed it is a static method, but I still have the same trouble.
-
@Xav12358
At the time you show the File Dialog do you have any other window/widget currently open/visible in your application? By default Qt widget applications are set to close and exit when the last visible window is closed, that might be your situation? -
Indeed I have the mainwindows already open. How could I change the option you mention?
@Xav12358
Well if you have the main window already open as you just wrote then the file dialog close will not be the last visible window to close so this won't apply? But I was talking about QGuiApplication::setQuitOnLastWindowClosed(bool quit), which one can set to false. -
@Xav12358
Well if you have the main window already open as you just wrote then the file dialog close will not be the last visible window to close so this won't apply? But I was talking about QGuiApplication::setQuitOnLastWindowClosed(bool quit), which one can set to false. -
S SGaist moved this topic from General and Desktop on