Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946
Pyside, how to propagate UI changes to parents
Whatever last edited by
This is my second day with Python and QT so forgive me for a likely newbie question.
I think my use case is common. I have a pull down menu called "View", in this menu there are QAction items that are checkable for enable and disable MDI windows showing data that is fed from an external HW.
Showing, hiding the window works well when using the menu only, but there is a close button on the window as well. If closing the window using the close button on the window, the "checked" status in the menu isn't updated.
I have manage to get this working by providing the MDI window, the associated QAction and toggle the status during closeEvent. If this is a good solution, I cannot say.
You can get my idea with this code:
@class MdiWindow(QWidget, Ui_Form):
def init(self, parent, action):
self._action = action
def closeEvent(self, event): self._action.setChecked(False)
class MainWindow(QMainWindow, Ui_MainWindow):
_subWindows = [None] * 10
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setupUi(self) self.actionData_Window.toggled.connect(self.toggleDataWindow1) def toggleDataWindow1(self): if self.actionData_Window.isChecked(): window = window(self, self.actionData_Window) subWindow = self.mdiArea.addSubWindow(window) self._subWindows = subWindow subWindow.show() else: self._subWindows.close() self._subWindows = None
if name == 'main':
app = QApplication(sys.argv)
frame = MainWindow()
I've read somewhere that you can use signals as well.
What is the proper way to solve this here?