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

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

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

      <legend id='A0Jxe'><style id='A0Jxe'><dir id='A0Jxe'><q id='A0Jxe'></q></dir></style></legend>
      • <bdo id='A0Jxe'></bdo><ul id='A0Jxe'></ul>
      1. 如何使用 QComboBox.setPlaceholderText?

        How do i use QComboBox.setPlaceholderText?(如何使用 QComboBox.setPlaceholderText?)

      2. <tfoot id='CyGL0'></tfoot>

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

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

                  本文介紹了如何使用 QComboBox.setPlaceholderText?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  在 Qt 5.15 中引入了 placeholderText 屬性 -

                  這是一個錯誤還是我錯過了什么?我怎樣才能做到這一點?

                  導入系統從 PyQt5 導入 QtWidgets從 PyQt5 導入 QtCore類 MainWindow(QtWidgets.QMainWindow):def __init__(self):超級().__init__()central_w = QtWidgets.QWidget()self.setCentralWidget(central_w)vbox = QtWidgets.QVBoxLayout()central_w.setLayout(vbox)self.combo_box = QtWidgets.QComboBox()self.combo_box.addItems([一"、二"、三"])self.combo_box.setPlaceholderText("這里有一些占位符文本")self.combo_box.setCurrentIndex(-1)vbox.addWidget(self.combo_box)如果 __name__ == __main__":應用程序 = QtWidgets.QApplication(sys.argv)主窗口 = 主窗口()main_window.show()app.exec_()

                  我沒有找到顯示占位符文本的方法.我試過在組合框中根本沒有項目,但即使這樣也不顯示占位符文本


                  這些是我正在運行的版本:

                  • Qt:5.15.2
                  • PyQt(Python 模塊)版本:5.15.2(這恰好與 Qt 版本相同,但有時可能略有不同)
                  • Python:3.8.5(默認,2020 年 7 月 28 日,12:59:40) [GCC 9.3.0]"
                  • 操作系統:Ubuntu 20.04.1 LTS(帶 Xfce)

                  PS:如果你想達到類似的效果(即:在可點擊區域上有一個文本,點擊后顯示帶有不同選項的下拉菜單)你可以使用 QPushButtonsetMenu 函數.文檔:https://doc.qt.io/qt-5/qpushbutton.html#setMenu

                  解決方案

                  查看Qt源碼的修改,發現Qt 5.15.0增加placeHolderText的功能,修改了currentText():

                  //https://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/widgets/qcombobox.cpp?h=5.15.0#n2344QString QComboBox::currentText() 常量{Q_D(const QComboBox);if (d->lineEdit)return d->lineEdit->text();else if (d->currentIndex.isValid())返回 d->itemText(d->currentIndex);別的return d->placeholderText;}

                  但這會產生不良影響,QTBUG-86580在 Qt 5.15.2 中被刪除:

                  QString QComboBox::currentText() const{Q_D(const QComboBox);if (d->lineEdit)return d->lineEdit->text();if (d->currentIndex.isValid())返回 d->itemText(d->currentIndex);返回 {};}

                  忘記糾正 placeHolder 不再可見的副作用.我已經報告了這個錯誤:QTBUG-90522.

                  考慮到上述情況,有以下備選方案:

                  • 使用 PyQt5/PySide2 5.15.0 或 5.15.1.

                  • 重寫paintEvent方法將placeHolderText設置為currentText:

                  導入系統從 PyQt5 導入 QtCore、QtGui、QtWidgets# 或者# 從 PySide2 導入 QtCore、QtGui、QtWidgets類組合框(QtWidgets.QComboBox):# https://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/widgets/qcombobox.cpp?h=5.15.2#n3173defpaintEvent(自我,事件):畫家 = QtWidgets.QStylePainter(self)Painter.setPen(self.palette().color(QtGui.QPalette.Text))# 繪制組合框框、focusrect 和 selected 等.opt = QtWidgets.QStyleOptionComboBox()self.initStyleOption(opt)Painter.drawComplexControl(QtWidgets.QStyle.CC_ComboBox,選擇)如果 self.currentIndex() <0:opt.palette.setBrush(QtGui.QPalette.ButtonText,opt.palette.brush(QtGui.QPalette.ButtonText).color().lighter(),)如果 self.placeholderText():opt.currentText = self.placeholderText()# 繪制圖標和文本Painter.drawControl(QtWidgets.QStyle.CE_ComboBoxLabel,選擇)類 MainWindow(QtWidgets.QMainWindow):def __init__(self):超級().__init__()self.combo_box = 組合框()self.combo_box.addItems([一"、二"、三"])self.combo_box.setPlaceholderText("這里有一些占位符文本")self.combo_box.setCurrentIndex(-1)central_w = QtWidgets.QWidget()self.setCentralWidget(central_w)vbox = QtWidgets.QVBoxLayout(central_w)vbox.addWidget(self.combo_box)如果 __name__ == __main__":應用程序 = QtWidgets.QApplication(sys.argv)主窗口 = 主窗口()main_window.show()app.exec_()

                  In Qt 5.15 the placeholderText property was introduced - link to documentation

                  However using setPlaceholderText doesn't do anything for me. When running the code below i don't get any text in the QComboBox (unless of course i select one of the three items)

                  Is this a bug or am i missing something? How can i make this work?

                  import sys
                  from PyQt5 import QtWidgets
                  from PyQt5 import QtCore
                  
                  
                  class MainWindow(QtWidgets.QMainWindow):
                      def __init__(self):
                          super().__init__()
                  
                          central_w = QtWidgets.QWidget()
                          self.setCentralWidget(central_w)
                          vbox = QtWidgets.QVBoxLayout()
                          central_w.setLayout(vbox)
                  
                          self.combo_box = QtWidgets.QComboBox()
                          self.combo_box.addItems(["one", "two", "three"])
                          self.combo_box.setPlaceholderText("Some placeholder text here")
                          self.combo_box.setCurrentIndex(-1)
                          vbox.addWidget(self.combo_box)
                  
                  
                  if __name__ == "__main__":
                      app = QtWidgets.QApplication(sys.argv)
                      main_window = MainWindow()
                      main_window.show()
                      app.exec_()
                  

                  I have found no way of showing the placeholder text. I've tried having no items at all in the combo box but even this doesn't show the placeholder text


                  These are the versions i am running:

                  • Qt: 5.15.2
                  • PyQt (Python module) version: 5.15.2 (this happens to be the same as the Qt version but can sometimes differ slightly)
                  • Python: "3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]"
                  • OS: Ubuntu 20.04.1 LTS (with Xfce)

                  PS: If you want to achieve a similar effect (that is: having a text on a clickable area which shows a drop-down with different options after being clicked) you can use a QPushButton with the setMenu function. Documentation: https://doc.qt.io/qt-5/qpushbutton.html#setMenu

                  解決方案

                  Reviewing the modifications of the Qt source code, it is observed that to add the functionality of the placeHolderText in Qt 5.15.0, the currentText() was modified:

                  // https://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/widgets/qcombobox.cpp?h=5.15.0#n2344
                  QString QComboBox::currentText() const
                  {
                      Q_D(const QComboBox);
                      if (d->lineEdit)
                          return d->lineEdit->text();
                      else if (d->currentIndex.isValid())
                          return d->itemText(d->currentIndex);
                      else
                          return d->placeholderText;
                  }
                  

                  But that generates an undesirable effect that was reported in QTBUG-86580 so that functionality was removed in Qt 5.15.2:

                  QString QComboBox::currentText() const
                  {
                      Q_D(const QComboBox);
                      if (d->lineEdit)
                          return d->lineEdit->text();
                      if (d->currentIndex.isValid())
                          return d->itemText(d->currentIndex);
                      return {};
                  }
                  

                  Forgetting to correct the side effect which is that the placeHolder is no longer visible. I have already reported the bug: QTBUG-90522.

                  Considering the above, there are the following alternatives:

                  • Use PyQt5/PySide2 5.15.0 or 5.15.1.

                  • Override the paintEvent method to set the placeHolderText as currentText:

                  import sys
                  from PyQt5 import QtCore, QtGui, QtWidgets
                  
                  # or
                  # from PySide2 import QtCore, QtGui, QtWidgets
                  
                  
                  class ComboBox(QtWidgets.QComboBox):
                      # https://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/widgets/qcombobox.cpp?h=5.15.2#n3173
                      def paintEvent(self, event):
                          
                          painter = QtWidgets.QStylePainter(self)
                          painter.setPen(self.palette().color(QtGui.QPalette.Text))
                  
                          # draw the combobox frame, focusrect and selected etc.
                          opt = QtWidgets.QStyleOptionComboBox()
                          self.initStyleOption(opt)
                          painter.drawComplexControl(QtWidgets.QStyle.CC_ComboBox, opt)
                  
                          if self.currentIndex() < 0:
                              opt.palette.setBrush(
                                  QtGui.QPalette.ButtonText,
                                  opt.palette.brush(QtGui.QPalette.ButtonText).color().lighter(),
                              )
                              if self.placeholderText():
                                  opt.currentText = self.placeholderText()
                  
                          # draw the icon and text
                          painter.drawControl(QtWidgets.QStyle.CE_ComboBoxLabel, opt)
                  
                  
                  class MainWindow(QtWidgets.QMainWindow):
                      def __init__(self):
                          super().__init__()
                  
                          self.combo_box = ComboBox()
                          self.combo_box.addItems(["one", "two", "three"])
                          self.combo_box.setPlaceholderText("Some placeholder text here")
                          self.combo_box.setCurrentIndex(-1)
                  
                          central_w = QtWidgets.QWidget()
                          self.setCentralWidget(central_w)
                          vbox = QtWidgets.QVBoxLayout(central_w)
                          vbox.addWidget(self.combo_box)
                  
                  
                  if __name__ == "__main__":
                      app = QtWidgets.QApplication(sys.argv)
                      main_window = MainWindow()
                      main_window.show()
                      app.exec_()
                  

                  這篇關于如何使用 QComboBox.setPlaceholderText?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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時顯示進度條?)

                      <tbody id='RuToi'></tbody>

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

                      • <tfoot id='RuToi'></tfoot>
                        • <bdo id='RuToi'></bdo><ul id='RuToi'></ul>

                          <i id='RuToi'><tr id='RuToi'><dt id='RuToi'><q id='RuToi'><span id='RuToi'><b id='RuToi'><form id='RuToi'><ins id='RuToi'></ins><ul id='RuToi'></ul><sub id='RuToi'></sub></form><legend id='RuToi'></legend><bdo id='RuToi'><pre id='RuToi'><center id='RuToi'></center></pre></bdo></b><th id='RuToi'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='RuToi'><tfoot id='RuToi'></tfoot><dl id='RuToi'><fieldset id='RuToi'></fieldset></dl></div>
                          <legend id='RuToi'><style id='RuToi'><dir id='RuToi'><q id='RuToi'></q></dir></style></legend>
                            主站蜘蛛池模板: 99re在线视频观看 | 国产高清一区二区三区 | 丁香婷婷久久久综合精品国产 | 毛片一区二区三区 | 国产精品成人一区二区三区 | 国产男女猛烈无遮掩视频免费网站 | 日韩一二区在线观看 | 久久久精品在线 | 久久久九九 | 欧美色综合一区二区三区 | 午夜精品一区二区三区免费视频 | 亚洲欧美一区二区三区在线 | 亚洲一区在线播放 | 亚洲三区视频 | 91免费视频观看 | 一区二区亚洲 | 在线a视频 | 午夜视频在线观看网站 | 91精品久久久久久综合五月天 | 欧美久久久久久 | 羞羞的视频免费在线观看 | 99久久夜色精品国产亚洲96 | 日韩在线看片 | 亚洲一区二区中文字幕 | 黄色毛片在线播放 | 天堂色综合| 一级片在线视频 | 一区二区在线不卡 | 毛片免费观看 | 久久999 | 精品在线一区二区 | 午夜男人的天堂 | 午夜激情免费视频 | 欧美一区免费 | 午夜视频免费在线观看 | 亚洲成人精选 | 在线中文字幕第一页 | 亚洲国产精品一区 | 欧美成人久久 | 精品欧美一区二区精品久久 | 日韩欧美在线视频观看 |