pyqt TreeWidget 取树形中所选中的项目(ID或者内容)
QtCore.QObject.connect(self.CTree,QtCore.SIGNAL("itemDoubleClicked(QTreeWidgetItem*,int)"),self.data_query)
def data_query(self, item, column):
if $$$$$ == a:
print "a"
如上所示,data_query函数中,$$$$$为鼠标所双击的项目(ID或者内容),我要如何写才能取到(ID或者内容)。
谢谢,新手啊!求解决啊。。。 pyqt?
[解决办法]
QTreeWidgetItem有data方法。http://pyqt.sourceforge.net/Docs/PyQt4/qtreewidgetitem.html#data
[解决办法]
就是pyqt中QTreeWidgetItem的文档。你安装了pyqt的话,也许本地机器上就有。节选如下:
QVariant QTreeWidgetItem.data (self, int column, int role)
Returns the value for the item's column and role.
See also setData().
setData的文档:
QTreeWidgetItem.setData (self, int column, int role, QVariant value)
Sets the value for the item's column and role to the given value.
The role describes the type of data specified by value, and is defined by the Qt.ItemDataRole enum.