QFileDialog getOpenFileName DontUseNativeDialog strange effect when dragging window
-
I use QFileDialog.getOpenFileName with option DontUseNativeDialog and not null parent. When I try to drag dialog window it is dragged together with parent widget window underneath (in my case qapp window). If parent window was maximized it is restored to previous size first. Is it planned behavior or a bug?
My environment: Qt 5.15.0, Ubuntu 20, Python 3.8.0, PyCharm. The same effect using PyQt5 and PySide2.
-
Hi and welcome to devnet,
Since you gave it a parent, I am not surprised to see both move together as the dialog is modal to the parent widget.. Can you provide a minimal example script that shows this ?
-
Hi and welcome to devnet,
Since you gave it a parent, I am not surprised to see both move together as the dialog is modal to the parent widget.. Can you provide a minimal example script that shows this ?
After upgrading PyQt5 to latest, PyQt version works as expected. In PySide2 windows are still pinned together.
from PySide2.QtWidgets import (QMainWindow, QAction, QFileDialog, QApplication) import sys class Example(QMainWindow): def __init__(self): super().__init__() self.initUI() def initUI(self): openFile = QAction('Open', self) openFile.triggered.connect(self.showDialog) menubar = self.menuBar() fileMenu = menubar.addMenu('&File') fileMenu.addAction(openFile) self.show() def showDialog(self): fname = QFileDialog.getOpenFileName(self, 'Open file', '/', options=QFileDialog.DontUseNativeDialog) app = QApplication() ex = Example() sys.exit(app.exec_())