pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    • <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="f7jtnf7" 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="9zlfvr7" 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?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我在單擊 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,但是當(dāng)我設(shè)置 QtWidgets.QPushButton 時出現(xiàn)問題.我在 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)
                

                最后開發(fā)了函數(shù)showId:

                And finally developed the function showId:

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

                當(dāng)我點擊我的按鈕時,窗口關(guān)閉了,這是什么問題?我分享了我的 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 對象轉(zhuǎn)換為 python 本機(jī)對象 方法,但在 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.

                這篇關(guān)于如何從 qcombobox 獲取 itemdata?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

                How to bind a function to an Action from Qt menubar?(如何將函數(shù)綁定到 Qt 菜單欄中的操作?)
                PyQt progress jumps to 100% after it starts(PyQt 啟動后進(jìn)度躍升至 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 刻度標(biāo)簽設(shè)置在固定位置,以便當(dāng)我向左或向右滾動時,yaxis 刻度標(biāo)簽應(yīng)該可見
                `QImage` constructor has unknown keyword `data`(`QImage` 構(gòu)造函數(shù)有未知關(guān)鍵字 `data`)
                Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進(jìn)度條?)
                  <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="d77rp73" 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>
                          主站蜘蛛池模板: 薄壁轴承-等截面薄壁轴承生产厂家-洛阳薄壁精密轴承有限公司 | HYDAC过滤器,HYDAC滤芯,现货ATOS油泵,ATOS比例阀-东莞市广联自动化科技有限公司 | led全彩屏-室内|学校|展厅|p3|户外|会议室|圆柱|p2.5LED显示屏-LED显示屏价格-LED互动地砖屏_蕙宇屏科技 | 暖气片十大品牌厂家_铜铝复合暖气片厂家_暖气片什么牌子好_欣鑫达散热器 | 上海乾拓贸易有限公司-日本SMC电磁阀_德国FESTO电磁阀_德国FESTO气缸 | 雾度仪_雾度计_透光率雾度仪价格-三恩时(3nh)光电雾度仪厂家 | 旋振筛|圆形摇摆筛|直线振动筛|滚筒筛|压榨机|河南天众机械设备有限公司 | 阴离子_阳离子聚丙烯酰胺厂家_聚合氯化铝价格_水处理絮凝剂_巩义市江源净水材料有限公司 | 小学教案模板_中学教师优秀教案_高中教学设计模板_教育巴巴 | 沈阳激光机-沈阳喷码机-沈阳光纤激光打标机-沈阳co2激光打标机 | 布袋除尘器-单机除尘器-脉冲除尘器-泊头市兴天环保设备有限公司 布袋除尘器|除尘器设备|除尘布袋|除尘设备_诺和环保设备 | 仓储笼_金属箱租赁_循环包装_铁网箱_蝴蝶笼租赁_酷龙仓储笼租赁 测试治具|过炉治具|过锡炉治具|工装夹具|测试夹具|允睿自动化设备 | 无锡门窗-系统门窗-阳光房-封阳台-断桥铝门窗厂[窗致美] | 电车线(用于供电给电车的输电线路)-百科 | TwistDx恒温扩增-RAA等温-Jackson抗体-默瑞(上海)生物科技有限公司 | 【德信自动化】点胶机_全自动点胶机_自动点胶机厂家_塑料热压机_自动螺丝机-深圳市德信自动化设备有限公司 | _网名词典_网名大全_qq网名_情侣网名_个性网名 | 河南不锈钢水箱_地埋水箱_镀锌板水箱_消防水箱厂家-河南联固供水设备有限公司 | 气力输送设备_料封泵_仓泵_散装机_气化板_压力释放阀-河南锐驰机械设备有限公司 | 纳米二氧化硅,白炭黑,阴离子乳化剂-臻丽拾科技 | 护栏打桩机-打桩机厂家-恒新重工 | 培训中心-翰香原香酥板栗饼加盟店总部-正宗板栗酥饼技术 | 通辽信息港 - 免费发布房产、招聘、求职、二手、商铺等信息 www.tlxxg.net | 飞飞影视_热门电影在线观看_影视大全| 江苏密集柜_电动_手动_移动_盛隆柜业江苏档案密集柜厂家 | [品牌官网]贵州遵义双宁口腔连锁_贵州遵义牙科医院哪家好_种植牙_牙齿矫正_原华美口腔 | 反渗透水处理设备|工业零排放|水厂设备|软化水设备|海南净水设备--海南水处理设备厂家 | 自动化展_机器人展_机床展_工业互联网展_广东佛山工博会 | 喷漆房_废气处理设备-湖北天地鑫环保设备有限公司 | 耐腐蚀泵,耐腐蚀真空泵,玻璃钢真空泵-淄博华舜耐腐蚀真空泵有限公司 | 深圳办公室装修,办公楼/写字楼装修设计,一级资质 - ADD写艺 | 三氯异氰尿酸-二氯-三氯-二氯异氰尿酸钠-优氯净-强氯精-消毒片-济南中北_优氯净厂家 | 北京亦庄厂房出租_经开区产业园招商信息平台| 首页_中夏易经起名网 | 盘煤仪,盘料仪,盘点仪,堆料测量仪,便携式激光盘煤仪-中科航宇(北京)自动化工程技术有限公司 | 河南空气能热水器-洛阳空气能采暖-洛阳太阳能热水工程-洛阳润达高科空气能商行 | 塑钢件_塑钢门窗配件_塑钢配件厂家-文安县启泰金属制品有限公司 深圳南财多媒体有限公司介绍 | 广州物流公司_广州货运公司_广州回程车运输 - 万信物流 | 废旧物资回收公司_广州废旧设备回收_报废设备物资回收-益美工厂设备回收公司 | 宽带办理,电信宽带,移动宽带,联通宽带,电信宽带办理,移动宽带办理,联通宽带办理 | 焊接烟尘净化器__焊烟除尘设备_打磨工作台_喷漆废气治理设备 -催化燃烧设备 _天津路博蓝天环保科技有限公司 |