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

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

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

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

      1. <tfoot id='aR0XC'></tfoot>
          <bdo id='aR0XC'></bdo><ul id='aR0XC'></ul>

      2. “QMessageBox.Yes"的替代方案對于 PyQt6

        Alternative to quot;QMessageBox.Yesquot; for PyQt6(“QMessageBox.Yes的替代方案對于 PyQt6)
        1. <legend id='ixBcV'><style id='ixBcV'><dir id='ixBcV'><q id='ixBcV'></q></dir></style></legend>

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

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

                <tbody id='ixBcV'></tbody>
              <tfoot id='ixBcV'></tfoot>

                • <bdo id='ixBcV'></bdo><ul id='ixBcV'></ul>
                  本文介紹了“QMessageBox.Yes"的替代方案對于 PyQt6的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試將我的腳本從 PyQt5 移植到 PyQt6.感謝this answer,我已經弄清楚了如何移植大部分內容,但是,我遇到了一個問題.

                  I am trying to port over a script of mine from PyQt5 to PyQt6. I have figured out how to port most of the things thanks to this answer, however, I have run into an issue.

                  我發現 PyQt6 使用 QtWidgets.QMessageBox.StandardButtons.Yes 而不是 PyQt5 的 QtWidgets.QMessageBox.Yes.

                  I have figured out that PyQt6 uses QtWidgets.QMessageBox.StandardButtons.Yes instead of PyQt5's QtWidgets.QMessageBox.Yes.

                  但是,當檢查用戶是否按下是"時打開 QMessageBox 后,將 QtWidgets.QMessageBox.Yes 替換為 QtWidgets.QMessageBox.StandardButtons.Yes 不起作用(請查看下面的示例).

                  However, when checking if the user pressed "Yes" after a QMessageBox opens, replacing QtWidgets.QMessageBox.Yes with QtWidgets.QMessageBox.StandardButtons.Yes doesn't work (check the examples below).

                  例子:

                  PyQt5:

                  reply = QtWidgets.QMessageBox()
                  reply.setText("Some random text.")
                  reply.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
                  
                  x = reply.exec_()
                  
                  if x == QtWidgets.QMessageBox.Yes:
                      print("Hello!")
                  

                  打印你好!"這里工作正常.(16384 == 16384)

                  Printing "Hello!" here works normally. (16384 == 16384)

                  PyQt6:

                  reply = QtWidgets.QMessageBox()
                  reply.setText("Some random text.")
                  reply.setStandardButtons(QtWidgets.QMessageBox.StandardButtons.Yes | 
                                           QtWidgets.QMessageBox.StandardButtons.No)
                  
                  x = reply.exec()
                  
                  if x == QtWidgets.QMessageBox.StandardButtons.Yes:
                      print("Hello!")
                  

                  你好!"這里根本不打印.(16384 != StandardButtons.yes)

                  "Hello!" here doesn't print at all. (16384 != StandardButtons.yes)

                  我知道我可以做到:

                  x = reply.exec()
                  
                  if x == 16384:
                      print("Hello!")
                  

                  因為,在按下是"后,QMessageBox 等于 16384 (看這個),但我想使用這種方法,而是使用類似 PyQt5 示例的方法.

                  because, after pressing "Yes", the QMessageBox equals to 16384 (see this), but I'd like to not use that approach, and rather use something like the PyQt5 example.

                  推薦答案

                  這有點奇怪.根據 QMessageBox.exec 的文檔:

                  This is kind of strange. According to the documentation for QMessageBox.exec:

                  當使用帶有標準按鈕的 QMessageBox 時,此函數返回一個 StandardButton 值,指示之前的標準按鈕點擊.

                  When using a QMessageBox with standard buttons, this function returns a StandardButton value indicating the standard button that was clicked.

                  您使用的是標準按鈕,所以這應該返回一個 QMessageBox.StandardButtons 枚舉.

                  You are using standard buttons, so this should return a QMessageBox.StandardButtons enum.

                  值得一提的是,在 PyQt5 中比較整數和枚舉不是問題,因為枚舉是用 enum.IntEnum 實現的.現在,它們是用 enum.Enum 實現的.來自 Riverbank Computing 網站:

                  It's also worth mentioning that comparing integers with enums was not a problem in PyQt5, because enums were implemented with enum.IntEnum. Now, they're implemented with enum.Enum. From the Riverbank Computing website:

                  現在所有枚舉都實現為 enum.Enum(PyQt5 使用 enum.IntEnum范圍枚舉和傳統命名枚舉的自定義類型).PyQt5每當需要枚舉時都允許使用 int 但 PyQt6 需要正確的類型.

                  All enums are now implemented as enum.Enum (PyQt5 used enum.IntEnum for scoped enums and a custom type for traditional named enums). PyQt5 allowed an int whenever an enum was expected but PyQt6 requires the correct type.

                  但是,出于某種原因,QMessageBox.exec 返回一個整數(我只是用 PyQt6==6.0.0 嘗試過)!

                  However, for some reason, QMessageBox.exec returns an integer (I just tried it with PyQt6==6.0.0)!

                  現在,您可以通過故意從返回的整數構造一個枚舉對象來解決這個問題:

                  For now, you can get around this by deliberately constructing an enum object from the returned integer:

                  if QtWidgets.QMessageBox.StandardButtons(x) == QtWidgets.QMessageBox.StandardButtons.Yes:
                              print("Hello!")
                  

                  而且,由于您是在比較枚舉,我建議您使用 is 而不是 ==.

                  And, since you're comparing enums, I would suggest using is rather than ==.

                  這篇關于“QMessageBox.Yes"的替代方案對于 PyQt6的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動后進度躍升至 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 刻度標簽設置在固定位置,以便當我向左或向右滾動時,yaxis 刻度標簽應該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構造函數有未知關鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)
                    <bdo id='klHxt'></bdo><ul id='klHxt'></ul>

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

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

                          <tbody id='klHxt'></tbody>

                            主站蜘蛛池模板: 久久精品一| 欧美成人一区二区三区 | 日韩精品在线观看一区二区三区 | 精品欧美一区二区三区久久久 | 一区二区在线 | 久久精品国产一区二区三区不卡 | 国产剧情一区 | 久久久久久免费免费 | 欧美精品在线免费观看 | 秋霞电影一区二区 | 成人福利电影 | 中文字幕电影在线观看 | 日本电影一区二区 | va精品| 手机在线观看 | 夜夜草导航 | 亚洲精品久久久一区二区三区 | 久草久草久草 | 亚洲国产欧美在线人成 | 精品自拍视频在线观看 | 亚洲最新网址 | 亚洲成人福利在线观看 | 免费看淫片 | 久久国产福利 | 久久久亚洲| gogo肉体亚洲高清在线视 | 亚洲免费在线 | 亚洲国产成人精品女人久久久 | 成人亚洲精品久久久久软件 | 99精品热视频 | 国产亚洲高清视频 | 色综合天天综合网国产成人网 | 久久久久久久av | 国产在线一区二区 | 亚洲精品福利视频 | www.日本在线观看 | 91成人在线 | 国产中文 | 中文字幕av在线播放 | 亚洲视频国产 | 国产电影一区二区三区爱妃记 |