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

循環(huán)中的 QtCore.QObject.connect 只影響最后一個實(shí)例

QtCore.QObject.connect in a loop only affects the last instance(循環(huán)中的 QtCore.QObject.connect 只影響最后一個實(shí)例)
本文介紹了循環(huán)中的 QtCore.QObject.connect 只影響最后一個實(shí)例的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我有一個循環(huán).我創(chuàng)建了一個 QCheckBox 并將它放在一個 QTableWidget 單元格中,一切正常.在循環(huán)的每一步中,我都為 myslot SLOT 調(diào)用了一個 connect 函數(shù),但只應(yīng)用了最后一個 QCheckBox 實(shí)例.我用谷歌搜索了很多,發(fā)現(xiàn)很多人都有我的問題.我已經(jīng)應(yīng)用了他們的解決方案,但我的問題仍然存在.

I have got a loop. I created a QCheckBox and put it in a QTableWidget cell, and everything is Ok. In each step of loop I have called a connect function, for myslot SLOT, but only the last QCheckBox instance is applied. I googled a lot and have found many people have my problem. I have applied their solutions, but my problem remains.

for row in xrange(len(uniqueFields)):
    instance = QtGui.QCheckBox(uniqueFields[row], findInstance.tableWidget)
    print QtCore.QObject.connect(instance,
        QtCore.SIGNAL(_fromUtf8("stateChanged (int)")),
        lambda: findInstance.projectsInstance.myslot(
                    "TWCH", findInstance, instance.text(),
                    instance.checkState(), instance))
    findInstance.tableWidget.setRowCount(findInstance.tableWidget.rowCount() + 1)
    findInstance.tableWidget.setCellWidget(row, 0, instance)

注意:我的connect函數(shù)返回True.

如何在枚舉所有實(shí)例的循環(huán)中創(chuàng)建connect函數(shù)?

How to create connect function in a loop that enumerates all of the instances?

推薦答案

我有同樣的問題,你應(yīng)該使用 functools.partial 如:

I have same problem , you should use functools.partial such as:

for key, val in a_DICT_THAT_YOU_STORED_YOUR_OBJECTS_AND_STRINGS:
    obj = partial(   findInstance.projectsInstance.myslot,arg1="TWCH",arg2=self,arg3=key,arg4=val.checkState() )
    QtCore.QObject.connect(val, QtCore.SIGNAL(_fromUtf8("stateChanged (int)")), obj)

當(dāng)然,argX 應(yīng)該設(shè)置為你的函數(shù)名參數(shù)的真實(shí)名稱.

Of course, argX should set to your real name of your argument of your function name.

這篇關(guān)于循環(huán)中的 QtCore.QObject.connect 只影響最后一個實(shí)例的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數(shù)據(jù)?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環(huán): for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環(huán)?)
Reusing thread in loop c++(在循環(huán) C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環(huán)形?)
主站蜘蛛池模板: 中文字幕日本一区二区 | 国产综合欧美 | xxx国产精品视频 | 九九色综合 | 成人二区 | 99re6在线 | 欧美a区 | 亚洲成人自拍网 | 国产99免费 | 久久久久亚洲精品 | 涩涩99| 中文字幕精品一区二区三区精品 | 国产精品视频999 | 精品视频一区二区三区在线观看 | 天天看片天天干 | 久久久久久99 | 久久精品a | 91视视频在线观看入口直接观看 | 狠狠干av| 粉嫩在线 | 成人一级黄色毛片 | 青青久草 | 九色在线视频 | 看片91| 人人人人干 | 欧美区在线 | 国产精品免费在线 | 99久视频 | 亚洲福利在线观看 | 久久久激情视频 | 欧美亚洲另类在线 | 国产黄色大片 | 国外成人在线视频网站 | 久久久久网站 | 免费国产一区二区视频 | 欧美视频第三页 | 97人人草 | 日本在线小视频 | 亚洲国产精品一区二区久久 | 91原创视频| 国产免费一区二区三区网站免费 |