示例#1
0
 def closeEvent(self, event):
     """
     Handling saving state before application when application is
     being closed.
     """
     settings = QtCore.QSettings()
     settings.clear()
     self.settings.save(settings)
     qApp.quit()
示例#2
0
    def contextMenuEvent(self, event):
        """也叫弹出式菜单, 就是右键单击弹出"""
        cmenu = QMenu(self)

        newAct = cmenu.addAction('New')
        openAct = cmenu.addAction('Open')
        quitAct = cmenu.addAction('Quit')

        # 从event获取位置信息, 通过mapToGlobal
        action = cmenu.exec_(self.mapToGlobal(event.pos()))
        if action == quitAct:
            qApp.quit()
示例#3
0
    def closeEvent(self, *args):
        """
        Handling saving state before application when application is
        being closed.
        """
        settings = QtCore.QSettings()
        settings.clear()
        self.settings.save(settings)

        if qApp is None:
            sys.exit()
        qApp.quit()
示例#4
0
    def closeEvent(self, event):
        """
        Handling saving state before application when application is
        being closed.
        """
        settings = QtCore.QSettings()
        settings.setValue("main_WindowGeometry", self.saveGeometry())
        settings.setValue("mainWindowState", self.saveState())
        self.settings.save(settings)

        #screen_shape = QtGui.QDesktopWidget().screenGeometry()
        main_window = self.window()
        width = main_window.frameGeometry().width()
        height = main_window.frameGeometry().height()
        settings.setValue('screen_shape', (width, height))

        qpos = self.pos()
        pos = qpos.x(), qpos.y()
        settings.setValue('pos', pos)
        qApp.quit()
示例#5
0
 def handle_quit(self):
     if self._env._ok_to_quit():
         qApp.quit()