tree_widget.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:opcua-widgets 作者: FreeOpcUa 项目源码 文件源码
def expand_to_node(self, node):
        """
        Expand tree until given node and select it
        """
        if isinstance(node, str):
            idxlist = self.model.match(self.model.index(0, 0), Qt.DisplayRole, node, 1, Qt.MatchExactly|Qt.MatchRecursive)
            node = self.model.data(idxlist[0], Qt.UserRole)
        path = node.get_path()
        for node in path:
            # FIXME: this would be the correct way if it would work
            #idxlist = self.model.match(self.model.index(0, 0), Qt.UserRole, QVariantnode, 2, Qt.MatchExactly|Qt.MatchRecursive)
            try:
                text = node.get_display_name().Text
            except UaError as ex:
                return
            idxlist = self.model.match(self.model.index(0, 0), Qt.DisplayRole, text, 1, Qt.MatchExactly|Qt.MatchRecursive)
            if idxlist:
                idx = idxlist[0]
                self.view.setExpanded(idx, True)
                self.view.setCurrentIndex(idx)
                self.view.activated.emit(idx)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号