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

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

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

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

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

      1. PyQt QToolButton在焦點時不更新圖標

        PyQt QToolButton not updating icon when in focus(PyQt QToolButton在焦點時不更新圖標)
        <tfoot id='U8Bmg'></tfoot>

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

          <tbody id='U8Bmg'></tbody>
          • <legend id='U8Bmg'><style id='U8Bmg'><dir id='U8Bmg'><q id='U8Bmg'></q></dir></style></legend>

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

                  本文介紹了PyQt QToolButton在焦點時不更新圖標的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我在更新使用 QToolButton 設置的按鈕的圖標時遇到問題.這個想法是將按鈕用于電影播放器??.播放時,按下按鈕,圖標變為暫停.再次按下時,播放暫停,圖標恢復播放.我有一些工作代碼,但問題是圖標沒有持續更新.如果我將 Qt 窗口保持在焦點上,則需要按下一兩個按鈕才能將圖標更改為預期圖像,此時實際圖像不是預期圖像(交換播放/暫停).

                  I'm having a problem updating the icon of a button set with QToolButton. The idea is to use the button for a movie player. To play, one presses the button and the icon changes to pause. When pressed again, play is paused and the icon reverts to play. I have some working code, but the problem is that the icon is not updating consistently. If I keep the Qt window in focus, it takes one or two button presses to change the icon to the intended image, by which time the actual image is not the intended image (swapped play/pause).

                  這是一些最小的示例代碼:

                  Here is some minimal example code:

                  from PyQt5.QtWidgets import QApplication, QVBoxLayout, QWidget, QStyle, QToolButton
                  
                  class Widget(QWidget):
                      def __init__(self, parent=None):
                          super(Widget, self).__init__(parent=parent)
                          self.play_button = QToolButton(clicked=self.update_button)
                          self.play_button.setIcon(self.style().standardIcon(QStyle.SP_MediaStop))
                          self.verticalLayout = QVBoxLayout(self)
                          self.verticalLayout.addWidget(self.play_button)
                  
                          self.button_pressed = False
                  
                      def update_button(self):
                          if self.button_pressed:
                              self.play_button.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay))
                              self.button_pressed = False
                              print("Button should be set to PLAY. Press is", self.button_pressed)
                          else:
                              self.play_button.setIcon(self.style().standardIcon(QStyle.SP_MediaPause))
                              self.button_pressed = True
                              print("Button should be set to PAUSE. Press is", self.button_pressed)
                  
                  
                  if __name__ == '__main__':
                      app = QApplication(sys.argv)
                      w = Widget()
                      w.show()
                      sys.exit(app.exec_())
                  

                  在上面我從一個停止圖標開始只是為了確保觀察到變化(任何點擊都應該總是改變圖標).保持窗口聚焦,我得到以下輸出:

                  In the above I start with a stop icon just to be sure to observe a change (any click should always change the icon). Keeping the window focused, I get the following output:

                  • 第一次點擊:按鈕應設置為暫停.按下為真"(圖標沒有變化)
                  • 第二次點擊:按鈕應設置為播放.按下為假"(圖標變為暫停)
                  • 第三次點擊:按鈕應設置為暫停.按下為真"(圖標變為播放)(依此類推,繼續按預期交換)

                  我還注意到,如果每次單擊后,我在 Qt 窗口之外單擊,或者調整 Qt 窗口的大小,按鈕圖標會更新為正確的圖標.我究竟做錯了什么?如何強制更新圖標?

                  I've also noticed that if after each click, I click outside the Qt window, or resize the Qt window, the button icon updates to the correct one. What am I doing wrong? How do I force the icon to update?

                  這種行為主要發生在 QToolButton 中,但 QPushButton 也會產生問題(在聚焦時有效,但如果我調整 Qt 窗口大小,則會出現錯誤行為/丟失正確狀態的跟蹤).在 macOS 上使用 PyQt 5.12.3 和 qt 5.12.5.

                  This behaviour happens mostly with QToolButton, but QPushButton also give issues (works when focused, but misbehaves/loses track of correct status if I resize the Qt window). Using PyQt 5.12.3 and qt 5.12.5 on macOS.

                  推薦答案

                  似乎這個問題是 macOS 的 Qt 實現中的一個錯誤.我測試過,它發生在 PyQt5 和 PySide2 上,所以它必須來自 Qt.在 .setIcon() 之后調用 .repaint() 強制重繪似乎可以解決問題:

                  Seems like this issue is a bug in the Qt implementation for macOS. I tested and it happens with both PyQt5 and PySide2, so it must come from Qt. Forcing a redraw with a call to .repaint() after .setIcon() seems to make the problem go away:

                  self.play_button.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay))
                  self.play_button.repaint()
                  

                  這篇關于PyQt QToolButton在焦點時不更新圖標的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='s6oiI'></bdo><ul id='s6oiI'></ul>

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

                              <tbody id='s6oiI'></tbody>

                            <tfoot id='s6oiI'></tfoot>
                          1. <i id='s6oiI'><tr id='s6oiI'><dt id='s6oiI'><q id='s6oiI'><span id='s6oiI'><b id='s6oiI'><form id='s6oiI'><ins id='s6oiI'></ins><ul id='s6oiI'></ul><sub id='s6oiI'></sub></form><legend id='s6oiI'></legend><bdo id='s6oiI'><pre id='s6oiI'><center id='s6oiI'></center></pre></bdo></b><th id='s6oiI'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='s6oiI'><tfoot id='s6oiI'></tfoot><dl id='s6oiI'><fieldset id='s6oiI'></fieldset></dl></div>
                          2. <legend id='s6oiI'><style id='s6oiI'><dir id='s6oiI'><q id='s6oiI'></q></dir></style></legend>
                          3. 主站蜘蛛池模板: 欧美a∨ | 一区二区三区在线观看免费视频 | 国产精品久久久久久福利一牛影视 | 羞羞视频网页 | www.久久久久久久久久久 | 在线观看亚洲精品视频 | 免费在线观看av的网站 | 麻豆久久久9性大片 | 日韩精品视频在线观看一区二区三区 | 国产一区 日韩 | h在线观看 | 国产精品永久免费 | av入口 | 欧美国产亚洲一区二区 | 欧美久| 成人精品在线观看 | 国产高清精品一区二区三区 | 久在线 | 拍戏被cao翻了h承欢 | 日韩在线观看中文字幕 | 国产精品久久久久久久久久免费看 | 天天综合天天 | 国产精品免费大片 | 日日综合 | 国产在线精品一区二区三区 | 中文字幕一二三区 | 免费一区二区三区 | 国产区在线视频 | 午夜免费成人 | 水蜜桃久久夜色精品一区 | 天堂av资源 | 久久久久久精 | 一区二区三区精品 | 免费精品视频 | 国产成人麻豆免费观看 | 欧美 日韩 亚洲91麻豆精品 | 免费的日批视频 | 99九九久久 | 久久不卡 | 黄色毛片大全 | 久草视 |