久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  1. <i id='uaii5'><tr id='uaii5'><dt id='uaii5'><q id='uaii5'><span id='uaii5'><b id='uaii5'><form id='uaii5'><ins id='uaii5'></ins><ul id='uaii5'></ul><sub id='uaii5'></sub></form><legend id='uaii5'></legend><bdo id='uaii5'><pre id='uaii5'><center id='uaii5'></center></pre></bdo></b><th id='uaii5'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='uaii5'><tfoot id='uaii5'></tfoot><dl id='uaii5'><fieldset id='uaii5'></fieldset></dl></div>

        <bdo id='uaii5'></bdo><ul id='uaii5'></ul>

      <small id='uaii5'></small><noframes id='uaii5'>

    1. <tfoot id='uaii5'></tfoot>

      <legend id='uaii5'><style id='uaii5'><dir id='uaii5'><q id='uaii5'></q></dir></style></legend>

      PyQt5 closeEvent 方法

      PyQt5 closeEvent method(PyQt5 closeEvent 方法)

        <i id='9oCIj'><tr id='9oCIj'><dt id='9oCIj'><q id='9oCIj'><span id='9oCIj'><b id='9oCIj'><form id='9oCIj'><ins id='9oCIj'></ins><ul id='9oCIj'></ul><sub id='9oCIj'></sub></form><legend id='9oCIj'></legend><bdo id='9oCIj'><pre id='9oCIj'><center id='9oCIj'></center></pre></bdo></b><th id='9oCIj'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='9oCIj'><tfoot id='9oCIj'></tfoot><dl id='9oCIj'><fieldset id='9oCIj'></fieldset></dl></div>
        <legend id='9oCIj'><style id='9oCIj'><dir id='9oCIj'><q id='9oCIj'></q></dir></style></legend>
              <tbody id='9oCIj'></tbody>

                <bdo id='9oCIj'></bdo><ul id='9oCIj'></ul>

                <tfoot id='9oCIj'></tfoot>

                <small id='9oCIj'></small><noframes id='9oCIj'>

                本文介紹了PyQt5 closeEvent 方法的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我目前正在學(xué)習(xí)如何使用 pyqt5 構(gòu)建應(yīng)用程序,但遇到了 closeEvent 方法的一些問題,已被覆蓋,因此 QMessageBox 對象要求用戶確認(rèn).它似乎與 X 按鈕配合得很好——當(dāng)操作被確認(rèn)時,事件被接受",當(dāng)點擊取消按鈕時,事件被取消".但是,當(dāng)我從下拉文件菜單中使用退出按鈕時,無論我單擊哪個按鈕,程序都會以退出代碼 1 關(guān)閉.看起來很奇怪,因為我在兩種情況下都使用相同的 closeEvent 方法.

                I'm currently learning how to build an application with pyqt5 and encountered some problem with closeEvent method, overriden so user gets asked for confirmation by QMessageBox object. It seems working well with X button - event gets 'accepted' when action is confirmed and 'canceled' when cancel button is clicked. However, when I use my Quit button from dropdown File menu, no matter which button I click, program gets closed with exit code 1. Seems strange, because I use same closeEvent method in both cases.

                import sys
                
                from PyQt5.QtWidgets import QApplication, QMessageBox, QMainWindow, QAction
                
                
                class window(QMainWindow):
                    def __init__(self):
                
                        super().__init__()
                
                    def createUI(self):
                
                
                        self.setGeometry(500, 300, 700, 700)
                
                        self.setWindowTitle("window")
                
                
                        quit = QAction("Quit", self)
                        quit.triggered.connect(self.closeEvent)
                
                        menubar = self.menuBar()
                        fmenu = menubar.addMenu("File")
                        fmenu.addAction(quit)
                
                    def closeEvent(self, event):
                        close = QMessageBox()
                        close.setText("You sure?")
                        close.setStandardButtons(QMessageBox.Yes | QMessageBox.Cancel)
                        close = close.exec()
                
                        if close == QMessageBox.Yes:
                            event.accept()
                        else:
                            event.ignore()
                
                main = QApplication(sys.argv)
                window = window()
                window.createUI()
                window.show()
                sys.exit(main.exec_())
                

                感謝您的建議!

                推薦答案

                當(dāng)您單擊按鈕時,程序會調(diào)用您的函數(shù),但使用不同的 event 對象,該對象沒有 accept()ignore() 所以你會收到錯誤消息并且程序以退出代碼 1 結(jié)束.

                When you click button then program calls your function but with different event object which doesn't have accept() and ignore() so you get error message and program ends with exit code 1.

                您可以分配 self.close 并且程序?qū)⑹褂谜_的事件對象調(diào)用 closeEvent().

                You can assign self.close and program will call closeEvent() with correct event object.

                quit.triggered.connect(self.close)
                

                這篇關(guān)于PyQt5 closeEvent 方法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                How to bind a function to an Action from Qt menubar?(如何將函數(shù)綁定到 Qt 菜單欄中的操作?)
                PyQt progress jumps to 100% after it starts(PyQt 啟動后進(jìn)度躍升至 100%)
                How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標(biāo)簽設(shè)置在固定位置,以便當(dāng)我向左或向右滾動時,yaxis 刻度標(biāo)簽應(yīng)該可見
                `QImage` constructor has unknown keyword `data`(`QImage` 構(gòu)造函數(shù)有未知關(guān)鍵字 `data`)
                Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進(jìn)度條?)
              • <tfoot id='lp2GP'></tfoot><legend id='lp2GP'><style id='lp2GP'><dir id='lp2GP'><q id='lp2GP'></q></dir></style></legend>

                  <tbody id='lp2GP'></tbody>
                  <bdo id='lp2GP'></bdo><ul id='lp2GP'></ul>

                  <small id='lp2GP'></small><noframes id='lp2GP'>

                    • <i id='lp2GP'><tr id='lp2GP'><dt id='lp2GP'><q id='lp2GP'><span id='lp2GP'><b id='lp2GP'><form id='lp2GP'><ins id='lp2GP'></ins><ul id='lp2GP'></ul><sub id='lp2GP'></sub></form><legend id='lp2GP'></legend><bdo id='lp2GP'><pre id='lp2GP'><center id='lp2GP'></center></pre></bdo></b><th id='lp2GP'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='lp2GP'><tfoot id='lp2GP'></tfoot><dl id='lp2GP'><fieldset id='lp2GP'></fieldset></dl></div>

                          主站蜘蛛池模板: a看片| 免费在线观看一级毛片 | 国产精品一区二区三级 | 亚洲一区二区三区免费在线观看 | 中文字幕在线观看日韩 | 黄网站在线播放 | 男女搞网站 | 伊人久久免费视频 | 欧美日韩国产中文 | 日日摸日日碰夜夜爽亚洲精品蜜乳 | 免费在线观看一区二区三区 | 福利片在线 | 久久精品一区二区三区四区 | 久久精品99 | 一级毛片免费完整视频 | 网站黄色av | 国产精品欧美一区二区三区不卡 | 天天曰天天干 | 国产精品乱码一区二区三区 | 亚洲第1页| 中文字幕在线一区二区三区 | 久久99国产精一区二区三区 | 亚洲一区网站 | 亚洲精品在线免费播放 | 欧美在线观看一区 | 一区二区影院 | 草草网 | 久久午夜电影 | av片网站| 久久久久久国产精品 | 国际精品鲁一鲁一区二区小说 | 999久久| 理伦毛片 | 日韩精品视频在线播放 | 人人99| 国产欧美一区二区三区在线看 | 亚洲国产网 | 国产在线观看 | 亚洲欧洲精品一区 | 中文欧美日韩 | 亚洲a人|