pyqt TreeWidget 取树形中所选中的项目(ID或者内容)

IKEA66 2013-08-01 05:26:54

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或者内容)。

谢谢,新手啊!求解决啊。。。
...全文
980 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
IKEA66 2013-08-02
  • 打赏
  • 举报
回复
引用 3 楼 panghuhu250 的回复:
就是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.
能不能给个具体的实例啊,谢谢!
panghuhu250 2013-08-02
  • 打赏
  • 举报
回复
就是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.
IKEA66 2013-08-02
  • 打赏
  • 举报
回复
引用 1 楼 panghuhu250 的回复:
QTreeWidgetItem有data方法。http://pyqt.sourceforge.net/Docs/PyQt4/qtreewidgetitem.html#data
不知道是公司网络的问题,还是什么原因,你所说的网站,无法访问
panghuhu250 2013-08-02
  • 打赏
  • 举报
回复
贴一段可以运行的完整代码,别人可以改一两句,告诉你怎么做。从头开始写一个例子,花的时间太多,做不了。
panghuhu250 2013-08-01
  • 打赏
  • 举报
回复
QTreeWidgetItem有data方法。http://pyqt.sourceforge.net/Docs/PyQt4/qtreewidgetitem.html#data

37,743

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧