qtreewidget

Delete QTreeWidgetItem in PyQt?

南笙酒味 提交于 2019-12-03 12:20:38
问题 I'm finding it frustratingly hard to find a simple way to delete my selected QTreeWidgetItem . My patchwork method involves setting the tree's current selection to current and then: if current.parent() is not None: current.parent().removeChild(current) else: self.viewer.takeTopLevelItem(self.viewer.indexOfTopLevelItem(current)) It's not horrible, but isn't there a command that straight up just removes the item? 回答1: The QTreeWidget class has an invisibleRootItem() function which allows for a

How to delete QTreeWidgetItem

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Several webpages say that QTreeWidgetItem can be deleted by deleting or QTreeWidget.clear ing. But my code sample below doesn't seem to do so. Am I doing anything wrong? #!/usr/bin/python import sys from PySide.QtGui import QApplication, QWidget, QTreeWidget, QTreeWidgetItem #from PyQt4.QtGui import QApplication, QWidget, QTreeWidget, QTreeWidgetItem # Result was the same with `PySide` import time class TreeWidgetItemChild(QTreeWidgetItem): def __init__(self): super(TreeWidgetItemChild, self).__init__() print 'TreeWidgetItemChild init' def _

QTreeWidget right click menu

▼魔方 西西 提交于 2019-12-03 07:39:38
问题 I looked around and it seems that the problem is present not only for tree widget but also for other widgets. But in my case, I found a solution, although an incomplete one. I am adding actions to my tree widget, so that when you right click on it, a popup with these actions appears. However, when I add items to my tree widget and I right click on them, the same popup appears. What I would like to do is that when you right click on the tree widget, a tree widget popup menu appears and when

Delete QTreeWidgetItem in PyQt?

北慕城南 提交于 2019-12-03 02:44:13
I'm finding it frustratingly hard to find a simple way to delete my selected QTreeWidgetItem . My patchwork method involves setting the tree's current selection to current and then: if current.parent() is not None: current.parent().removeChild(current) else: self.viewer.takeTopLevelItem(self.viewer.indexOfTopLevelItem(current)) It's not horrible, but isn't there a command that straight up just removes the item? The QTreeWidget class has an invisibleRootItem() function which allows for a somewhat neater approach: root = tree.invisibleRootItem() for item in tree.selectedItems(): (item.parent()

QTreeWidget expand sign

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: How to make expandable sign in QTreeWidget always visible even when item doest have any subitems? And how to draw something else instead of default sign? Thanks in advance, Serge 回答1: QTreeWidgetItems have the property childIndicatorPolicy . The allowed values are: QTreeWidgetItem::ShowIndicator QTreeWidgetItem::DontShowIndicator QTreeWidgetItem::DontShowIndicatorWhenChildless You want the first one. theItem . setChildIndicatorPolicy ( QTreeWidgetItem . ShowIndicator ) 回答2: Answering on my second part of question for others. I

QTreeWidget and QFileSystemModel

匿名 (未验证) 提交于 2019-12-03 01:39:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Please tell me how to connect to QFileSystemModel QTreeWidget simply function SetModel() not support QFileSystemModel but only QAbstractItemModel, but I need to work with files and for these purposes QAbstractItemModel not fit, I would like to open files in directories climb QTreeWidget. Thanx 回答1: setModel is a private function in QTreeWidget. To use it, you could create a custom TreeWidget class that inherits QtreeWidget and QTreeView, create a public function setModel(QAbstractItemModel *model) and in it call the QTreeView setModel

QTreeView or QTreeWidget

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to implement in my program a tree with nested sub-levels, and I'm looking for which of those two kind(View/Widget) is best suited for my goal. I have a list of days with task that are either done/missed/failed, each task has a count of how many times it was done/missed/failed and lastly a score for that day. I want to display them like so: I made this example in QtCreator using a QTreeWidget, but I'm worried that it would be hard to modify the elements since they are stored somewhere else. Are my worries rational and should I go to

PyQt5―高级界面控件(2)

匿名 (未验证) 提交于 2019-12-02 23:55:01
表格和树 高级界面控件 一、表格和树 5、QTreeView 高级界面控件 一、表格和树 5、QTreeView QTreeWidget 类实现了树形结构,其子类是 QTreeWidget。 QTreeWidget 类的常用方法如下表: 方法 描述 setColumnWidth(int column, int width) 将指定列的宽度设置为指定值 insertTopLevelItems() 在视图的顶层索引插入项目目录 expandAll() 展开所有树形节点 invisiblieRootItem() 返回树形控件中不可见的根选项 selectedItems() 返回所有选定的非隐藏项目的列表 来源:51CTO 作者: 御承扬 链接:https://blog.csdn.net/qq_42896653/article/details/100074302

QTreeWidget right click menu

我只是一个虾纸丫 提交于 2019-12-02 22:39:06
I looked around and it seems that the problem is present not only for tree widget but also for other widgets. But in my case, I found a solution, although an incomplete one. I am adding actions to my tree widget, so that when you right click on it, a popup with these actions appears. However, when I add items to my tree widget and I right click on them, the same popup appears. What I would like to do is that when you right click on the tree widget, a tree widget popup menu appears and when you right click on items, another corresponding popup menu appears. Does anybody knows how to do this?

初识QT(三十五)——Qt QTreeWidget和QDockWidget用法完全攻略(实例分析)

旧巷老猫 提交于 2019-12-02 14:50:02
本节介绍QTreeWidget、QDockWidget的使用,以及用 QLabel 显示图片的方法。实例 samp4_8 QTreeWidget 以 QTreeWidget 为主要组件,创建一个照片管理器,实例运行时的界面如图 1 所示。 图 1 实例Samp4_8运行时界面 这个实例主要演示如下几个组件的使用方法。 QTreeWidget 目录树组件:QTreeWidget 类是创建和管理目录树结构的类。实例使用一个 QTreeWidget 组件管理照片目录,可以添加、删除节点,每个节点设置一个自定义类型,另外,还设置了一个自定义数据,图片节点存储完整文件名,以便单击节点时显示该图片。 QDockWidget 停靠区域组件:QDockWidget 是可以在 QMainWindow 窗口停靠,或在桌面最上层浮动的界面组件。本实例将一个 QTreeWidget 组件放置在 QDockWidget 区域上,设置其可以在主窗口的左或右侧停靠,也可以浮动。 QLabel 组件显示图片:右侧是一个 QScrollArea 组件,ScrollArea 上面放置一个 QLabel 组件,通过为 QLabel 设置一个 QPixmap 显示图片。通过 QPixmap 操作可进行缩放显示,包括放大、缩小、实际大小、适合宽度、适合高度等。 界面设计 界面布局设计 实例 Samp4_8 的主窗口从