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

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

      <small id='1zMgi'></small><noframes id='1zMgi'>

      <legend id='1zMgi'><style id='1zMgi'><dir id='1zMgi'><q id='1zMgi'></q></dir></style></legend>

      如何從 qcombobox 獲取 itemdata?

      How can I get itemdata from qcombobox?(如何從 qcombobox 獲取 itemdata?)

        • <legend id='ydoOI'><style id='ydoOI'><dir id='ydoOI'><q id='ydoOI'></q></dir></style></legend>

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

            <tbody id='ydoOI'></tbody>

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

            <tfoot id='ydoOI'></tfoot>
              <bdo id='ydoOI'></bdo><ul id='ydoOI'></ul>

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

                問題描述

                我在單擊 QtWidgets.QPushButton 以顯示 QtWidgets.QComboBox 中的 itemData 時遇到問題.我用這段代碼填充我的 ComboBox:

                I have a problem when I clicked in a QtWidgets.QPushButton to show the itemData from a QtWidgets.QComboBox. I fill my ComboBox with this code:

                self.comboBox.addItem("Sandro",1)
                self.comboBox.addItem("Daniel",2)
                self.comboBox.addItem("Pedro",3)
                

                它填充了 QtWidgets.QComboBox,但是當我設置 QtWidgets.QPushButton 時出現問題.我在 setupUi 中添加了這個:

                It filled the QtWidgets.QComboBox, however the problem appears when I set the QtWidgets.QPushButton. I added this in the setupUi:

                self.pushButton.clicked.connect(self.showId)
                

                最后開發了函數showId:

                And finally developed the function showId:

                id_us = self.comboBox.itemData(self.comboBox.currentIndex())
                print('VAL ',id_us)
                

                當我點擊我的按鈕時,窗口關閉了,這是什么問題?我分享了我的 accessForm.py 的所有代碼:

                When I clicked my button, the windows closes, What was the problem? I share all the code of my accessForm.py:

                # -*- coding: utf-8 -*-
                from PyQt5 import QtCore, QtGui, QtWidgets
                class Ui_Form(object):
                    def setupUi(self, Form):
                        Form.setObjectName("Form")
                        Form.resize(598, 245)
                        self.groupBox = QtWidgets.QGroupBox(Form)
                        self.groupBox.setGeometry(QtCore.QRect(10, 20, 541, 201))
                        self.groupBox.setObjectName("groupBox")
                        self.pushButton = QtWidgets.QPushButton(self.groupBox)
                        self.pushButton.setGeometry(QtCore.QRect(50, 150, 75, 23))
                        self.pushButton.setObjectName("pushButton")
                        self.label = QtWidgets.QLabel(self.groupBox)
                        self.label.setGeometry(QtCore.QRect(40, 30, 47, 13))
                        self.label.setObjectName("label")
                        self.comboBox = QtWidgets.QComboBox(self.groupBox)
                        self.comboBox.setGeometry(QtCore.QRect(110, 30, 111, 22))
                        self.comboBox.setObjectName("comboBox")
                        self.retranslateUi(Form)
                        QtCore.QMetaObject.connectSlotsByName(Form)
                        self.fillCombo()
                        self.pushButton.clicked.connect(self.showId)
                    def retranslateUi(self, Form):
                        _translate = QtCore.QCoreApplication.translate
                        Form.setWindowTitle(_translate("Form", "Form"))
                        self.groupBox.setTitle(_translate("Form", "Datos"))
                        self.pushButton.setText(_translate("Form", "Inicio"))
                        self.label.setText(_translate("Form", "TextLabel"))
                    def showId(self):
                        id_us = self.comboBox.itemData(self.comboBox.currentIndex()).toPyObject()
                        print('VAL ',id_us)
                    def fillCombo(self):
                        self.comboBox.addItem("Sandro",1)
                        self.comboBox.addItem("Daniel",2)
                        self.comboBox.addItem("Pedro",3)
                if __name__ == "__main__":
                    import sys
                    app = QtWidgets.QApplication(sys.argv)
                    Form = QtWidgets.QWidget()
                    ui = Ui_Form()
                    ui.setupUi(Form)
                    Form.show()
                    sys.exit(app.exec_())
                

                提前致謝.

                推薦答案

                在我看來,您使用的是過時的教程,在 PyQt4 中,您必須使用 toPyObject() 將 PyQt 對象轉換為 python 本機對象 方法,但在 PyQt5 中不再需要:

                It seems to me that you are using an outdated tutorial, in PyQt4 you had to convert the PyQt object to python native object using the toPyObject() method, but in PyQt5 it is no longer necessary:

                def showId(self):
                    id_us = self.comboBox.itemData(self.comboBox.currentIndex()) # .toPyObject()
                    print('VAL ',id_us)
                

                作為建議,它使用終端或 CMD 來獲取錯誤消息,因為 IDE 在處理 PyQt 錯誤消息方面存在問題.

                As a recommendation, it uses the terminal or CMD to obtain the error messages since the IDEs have problems with handling the PyQt error messages.

                這篇關于如何從 qcombobox 獲取 itemdata?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='jMRMK'></tbody>
              • <legend id='jMRMK'><style id='jMRMK'><dir id='jMRMK'><q id='jMRMK'></q></dir></style></legend>
                <i id='jMRMK'><tr id='jMRMK'><dt id='jMRMK'><q id='jMRMK'><span id='jMRMK'><b id='jMRMK'><form id='jMRMK'><ins id='jMRMK'></ins><ul id='jMRMK'></ul><sub id='jMRMK'></sub></form><legend id='jMRMK'></legend><bdo id='jMRMK'><pre id='jMRMK'><center id='jMRMK'></center></pre></bdo></b><th id='jMRMK'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='jMRMK'><tfoot id='jMRMK'></tfoot><dl id='jMRMK'><fieldset id='jMRMK'></fieldset></dl></div>

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

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

                          <bdo id='jMRMK'></bdo><ul id='jMRMK'></ul>
                          主站蜘蛛池模板: 国产精彩视频 | 91禁蘑菇在线看 | 天天做天天操 | 日日爱视频 | 一区二区三区在线看 | 91精品国产综合久久久蜜臀九色 | 最近中文字幕在线 | 欧美黄色一级视频 | 日韩精品视频免费在线观看 | 一区在线观看视频 | 中文字幕日韩一区 | 美女操操操 | 亚洲午夜在线观看 | 中文字幕在线视频播放 | 久久伊人av | 黄色片视频网站 | 欧美专区第一页 | 欧美视频在线观看免费 | 欧美日韩免费 | 久久免费国产 | 欧美一级色| 天堂av片 | 操出白浆视频 | 激情小说图片视频 | 亚洲三级网站 | 国产日韩欧美 | aaa黄色片 | 欧美理论在线观看 | 日韩精品免费一区二区夜夜嗨 | 日韩一区二区三区在线播放 | 欧美偷拍精品 | 久久夜色精品 | 成年视频在线观看 | 亚洲天堂日本 | 香蕉成人| 福利片国产| 国产永久在线 | 国产精品视频免费 | 超碰在线网站 | 欧美精品三级 | 国产精品免费一区 |