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

  1. <small id='oRowP'></small><noframes id='oRowP'>

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

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

      如何將 QCompleter 與 InputDialog 一起使用?

      How to use QCompleter with an InputDialog?(如何將 QCompleter 與 InputDialog 一起使用?)

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

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

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

                <legend id='F9TWR'><style id='F9TWR'><dir id='F9TWR'><q id='F9TWR'></q></dir></style></legend><tfoot id='F9TWR'></tfoot>
                本文介紹了如何將 QCompleter 與 InputDialog 一起使用?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在編寫一個 Python 應用程序,用戶可以在其中在 QInputDialog 中輸入一個字符串.如何使用 QCompleter 使輸入更容易?

                I am writing a Python Application where the user can enter a String in an QInputDialog. How can i use the QCompleter to make Inputs easier?

                我已經在不同的網站上搜索并閱讀了文檔https://doc.qt.io/qt-5/qcompleter.html#詳情但找不到任何解決此問題的方法.

                I've already been searching on different websites and read the doc from https://doc.qt.io/qt-5/qcompleter.html#details but couldn't find any help for this problem.

                在我看來,QCompleter 似乎只適用于 QLineEdit 和 QComboBox.(請證明我錯了)

                To me, it seems like the QCompleter is only available for QLineEdit and QComboBox. (Please proof me wrong)

                ian, okPressed = QInputDialog.getText(self, "IAN", "Please enter IAN:")
                

                如果有人可以向我展示一些如何處理此問題的代碼示例,那將對我有很大幫助.

                It would help me a lot if anyone could show me some code examples how to deal with this problem.

                如果不能在 QInputDialog 中使用 QCompleter,你們有解決方法的想法嗎?

                If it's not possible to use the QCompleter within the QInputDialog, do you guys have an idea for a workaround?

                非常感謝 =)

                推薦答案

                有兩種可能的解決方案:

                There are 2 possible solutions:

                • 通過父級獲取QInputDialog- 使用 findChild():
                from PyQt5 import QtCore, QtGui, QtWidgets
                
                
                class Widget(QtWidgets.QWidget):
                    def __init__(self, parent=None):
                        super(Widget, self).__init__(parent)
                
                        button = QtWidgets.QPushButton("Press me", clicked=self.onClicked)
                        lay = QtWidgets.QVBoxLayout(self)
                        lay.addWidget(button)
                
                    @QtCore.pyqtSlot()
                    def onClicked(self):
                        QtCore.QTimer.singleShot(0, self.onTimeout)
                        ian, okPressed = QtWidgets.QInputDialog.getText(
                            self, "IAN", "Please enter IAN:"
                        )
                
                    @QtCore.pyqtSlot()
                    def onTimeout(self):
                        dialog = self.findChild(QtWidgets.QInputDialog)
                        if dialog is not None:
                            le = dialog.findChild(QtWidgets.QLineEdit)
                            if le is not None:
                                words = ["alpha", "omega", "omicron", "zeta"]
                                completer = QtWidgets.QCompleter(words, le)
                                le.setCompleter(completer)
                
                
                if __name__ == "__main__":
                    import sys
                
                    app = QtWidgets.QApplication(sys.argv)
                    w = Widget()
                    w.resize(320, 240)
                    w.show()
                    sys.exit(app.exec_())
                

                • 不要使用靜態方法并創建 QInputDialog 具有相同的元素:
                • from PyQt5 import QtCore, QtGui, QtWidgets
                  
                  
                  class Widget(QtWidgets.QWidget):
                      def __init__(self, parent=None):
                          super(Widget, self).__init__(parent)
                  
                          button = QtWidgets.QPushButton("Press me", clicked=self.onClicked)
                          lay = QtWidgets.QVBoxLayout(self)
                          lay.addWidget(button)
                  
                      @QtCore.pyqtSlot()
                      def onClicked(self):
                          dialog = QtWidgets.QInputDialog(self)
                          dialog.setWindowTitle("IAN")
                          dialog.setLabelText("Please enter IAN:")
                          dialog.setTextValue("")
                          le = dialog.findChild(QtWidgets.QLineEdit)
                          words = ["alpha", "omega", "omicron", "zeta"]
                          completer = QtWidgets.QCompleter(words, le)
                          le.setCompleter(completer)
                  
                          ok, text = (
                              dialog.exec_() == QtWidgets.QDialog.Accepted,
                              dialog.textValue(),
                          )
                          if ok:
                              print(text)
                  
                  
                  if __name__ == "__main__":
                      import sys
                  
                      app = QtWidgets.QApplication(sys.argv)
                      w = Widget()
                      w.resize(320, 240)
                      w.show()
                      sys.exit(app.exec_())
                  

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

                <small id='0YRgy'></small><noframes id='0YRgy'>

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

                        <tbody id='0YRgy'></tbody>
                          <legend id='0YRgy'><style id='0YRgy'><dir id='0YRgy'><q id='0YRgy'></q></dir></style></legend>
                          <tfoot id='0YRgy'></tfoot>
                        1. 主站蜘蛛池模板: 日韩在线视频一区二区三区 | 亚洲精品免费在线观看 | 华丽的挑战在线观看 | 亚洲精品一区二区三区在线 | 99精品国产一区二区三区 | 国产午夜精品一区二区三区四区 | 久久精品网| 天堂一区 | 国产亚洲一区二区三区 | 午夜免费福利影院 | 久久高清 | 韩日精品在线观看 | 国产日产精品一区二区三区四区 | 黄色毛片在线播放 | 韩国精品一区二区三区 | 紧缚调教一区二区三区视频 | 久草中文网 | 免费一区二区 | 日韩久久综合 | 精品不卡| 看片wwwwwwwwwww | 免费黄色的视频 | 国产黄色电影 | 精品96久久久久久中文字幕无 | 色吊丝2288sds中文字幕 | a在线观看免费 | 久久99深爱久久99精品 | 欧美成人免费 | 欧美日韩在线视频一区 | 中文字幕免费中文 | 欧美一区二区三区精品免费 | 欧美成人影院 | 国产一区二区在线免费播放 | 日韩精品一区二区三区四区视频 | 国产在线观看一区二区 | 成人激情视频免费观看 | 天天射天天干 | 亚洲国产精品视频 | 国产欧美日韩在线观看 | 国产精品久久久久久久7777 | 天天综合91|