Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Pyside, how to propagate UI changes to parents

Pyside, how to propagate UI changes to parents

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 756 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Whatever
    wrote on last edited by
    #1

    Hello

    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):
    super(MdiWindow, self).init(parent)
    self._action = action
    self.setupUi(self)

    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[0] = subWindow
            subWindow.show()
        else:
            self._subWindows[0].close()
            self._subWindows[0] = None
    

    if name == 'main':
    app = QApplication(sys.argv)
    frame = MainWindow()
    frame.show()
    app.exec_()@

    I've read somewhere that you can use signals as well.

    What is the proper way to solve this here?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved