qtreewidget

Qt Drag and drop between QTreeWidget

六月ゝ 毕业季﹏ 提交于 2020-06-26 12:07:30
问题 In my QT application I have two QTreeWidget A and B. I want rewrite drag and drop function for this two behavior: From A to A move items with all childrens. From B to A copy items with all childrens. I have view that in dropEvent function I have event.source() for take source. But how change function with flag for movement or copy dinamically? There is an example? Thanks 回答1: In order to perform this task we must distinguish if the action comes from himself or another widget for it is

Reorder items in a tree

两盒软妹~` 提交于 2020-05-30 16:14:59
问题 I want to be able to reorder the items in my_tree and I have somewhat achieved this as follows: my_tree.setDragEnabled(True) my_tree.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove) my_tree.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) However, I would like to restrict this behaviour only at the same level. Consider the following toy example: from PyQt5 import QtWidgets, QtGui, QtCore class MainWindow(QtWidgets.QMainWindow): def __init__(self): super(MainWindow, self).

Reorder items in a tree

守給你的承諾、 提交于 2020-05-30 16:14:13
问题 I want to be able to reorder the items in my_tree and I have somewhat achieved this as follows: my_tree.setDragEnabled(True) my_tree.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove) my_tree.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) However, I would like to restrict this behaviour only at the same level. Consider the following toy example: from PyQt5 import QtWidgets, QtGui, QtCore class MainWindow(QtWidgets.QMainWindow): def __init__(self): super(MainWindow, self).

Signal a QTreeWidgetItem toggled checkbox

不问归期 提交于 2020-05-23 09:48:44
问题 How do I check if a checkbox is checked or unchecked? (In QTreeWidget) shows how to get the status of the checkbox on a qtreewidget item. Using that method, with a signal for itemClicked in the Tree, I can query if the selected item is checked or not. However, I then need to keep track of this item to see if it was previously checked or not. Is there a method for knowing that a QTreeWidgetItem, which may be at different levels from the parent items, has a toggled checkbox, without making a

QT中的树型控件QTreeWidget和checkstate的使用

◇◆丶佛笑我妖孽 提交于 2020-04-07 02:07:27
今天简单说一下Qt的树形控件,在Qt中树形控件的名称叫做QTreeWidget,而控件里的树节点的名称叫做QTreeWidgetItem 。今天这 里讲的是如何创建具有复选框的树形控件: 当选中顶层的树形节点时,子节点全部被选中,当取消顶层树形节点时,子节点全部被取消选中状态,而当选中子节点时,父节点显示部分选中的状态。 要实现这种界面其实很简单的。在Qt的设计器中,拖出一个QTreeWidget,然后在主窗口中写一个函数init初始化界面,连接树形控件的节点改变 信号itemChanged(QTreeWidgetItem* item, int column),实现这个信号的即可。下面是具体代码: ui ->setupUi( this ); init(); connect( ui -> treeWidget , SIGNAL (itemChanged( QTreeWidgetItem *, int )), this , SLOT (treeItemChanged( QTreeWidgetItem *, int ))); void TreeWidgetTest::init() { ui.treeWidget->clear(); //第一个分组 QTreeWidgetItem *group1 = new QTreeWidgetItem(ui.treeWidget); group1-

QT之音乐播放器

和自甴很熟 提交于 2020-02-27 08:37:36
2020-2-26,项目耗时:2天 实现的功能 依据歌曲作者对歌曲进行分类,并以树状目录的结构显示在界面上 进度条实现 播放、暂停、音量调节 显示当前歌曲名 效果如下 模块划分 歌曲目录树模块:用来将歌曲文件以目录树的形式展现在界面上,并向外界提供当前被选中歌曲的路径信息。 控制面板模块:用来控制播放器的行为,以及反应播放器的状态。 播放器模块:播放器引擎,用来执行音乐文件的播放。 顶层模块:用来将以上模块组合在一起。 下面一一介绍每个模块的实现。 歌曲目录树模块 主要用到了一个QTreeWidget类,我从这个类派生出一个MusicTreeList类,关于QTreeWidget的详细说明见帮助文档。 music_tree_list.h # ifndef MUSIC_TREE_LIST_H # define MUSIC_TREE_LIST_H # include "QTreeWidget" class MusicTreeList : public QTreeWidget { Q_OBJECT public : MusicTreeList ( ) ; ~ MusicTreeList ( ) ; public slots : void musicChanged ( QTreeWidgetItem * item , int column ) ; signals : void

第15.27节 PyQt(Python+Qt)入门学习:Model/View架构中的便利类QTreeWidget详解

☆樱花仙子☆ 提交于 2020-02-26 13:34:24
老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 一、引言 树部件(Tree Widget)是Qt Designer中 Item Widgets(Item-Based)部件中提供的一个Model/View便利部件,对应类为QTreeWidget类。 QTreeWidget类从QTreeView派生(继承关系请参考《 PyQt学习随笔:Qt中Model/View相关的主要类及继承关系 》),是一个Model/View便利类,提供一个树状管理数据的界面视图,为了快速支持树状视图展示数据,在类内使用了默认内置的树状模型保存数据项,每个数据项的类型都是QTreeWidgetItem对象。 不需要Model/View框架灵活性的开发人员可以很容易地使用QTreeWidget类来创建简单的树状分层列表,但使用QTreeView 与标准项目模型相结合则更灵活,因为QTreeView 与标准项目模型允许将数据的存储与其界面呈现分离。 一个QTreeWidget类对象包括一个界面上显示的部件框架及对应视口(关于视口请参考《 PyQt(Python+Qt)学习随笔:QAbstractScrollArea的viewPort(视口)理解 》)、头部标题项、数据项等部分组成。 二、树型部件中的QTreeWidgetItem项 树型部件的项是单独的类对象

How to reach content in QTreeWidget second colum QComboBox?

喜你入骨 提交于 2020-02-15 10:17:21
问题 I have an AppDialog(QtGui.QWidget) containing a QtreeWidget . self.tree = QtGui.QTreeWidget() I populate data from self.sequences to this QtreeWidget with the function seqTree . Datas from self.sequences : {'090': {'090-0010': [ {'code': '090-0010_v000', 'type': 'Version', 'id': 26676, 'entity.Shot.sg_sequence.Sequence.code': '090', 'entity.Shot.code': '090-0010'}, {'code': '090-0010_maquette_v001', 'type': 'Version', 'id': 27848, 'entity.Shot.sg_sequence.Sequence.code': '090', 'entity.Shot

Tracking checked items in QTreeWidget when loading in new set of data

我与影子孤独终老i 提交于 2020-02-07 04:03:26
问题 I have a QTreeWidget in my gui in which the contents will be cleared whenever it loads in a different set of data and I am trying to tracked what has been checked as User loads in different data set. Initially, I thought of tracking it using derive_tree_items method that I created in which it contains the QTreeWidgetItem object, however as soon as I tried to load in a new set of data, the objects that I stored will be lost as they are deleted (expected).. Currently at a lost what is a better

QWidget::paintEngine: Should no longer be called in a QTreeWidget derived class [duplicate]

為{幸葍}努か 提交于 2020-01-30 13:14:08
问题 This question already has answers here : paintEvent in QTableView derived class: Paint device returned engine == 0, type: 1 (1 answer) Warning QPainter inside paintEvent [duplicate] (1 answer) Closed 2 years ago . I have a class, MyTree , which derived from QTreeWidget and void MyTree::paintEvent(QPaintEvent *event) { QPainter painter(this); } causes to raise the following issue, QWidget::paintEngine: Should no longer be called QPainter::begin: Paint device returned engine == 0, type: 1 Could