qtreewidget

Drag Drop Operation in QTreeWidget not copying the dropped item

心不动则不痛 提交于 2020-01-25 04:15:53
问题 I want to copy an item from a QTreeWidget -parent under another parent via a drag & drop mouse operation. For this, I have implemented the dropEvent() and am setting the dropAction to Qt.CopyAction . But anyway, the item I am dropping is not being copied under the new parent. E.g. -> dragging the user "schmidt" under the group "LON". Expected behaviour: the item I am dropping is being copied under the new parent. (e.g. user "schmidt" will be added under group "LON"). Full working code example

python/pyside using a custom widget in a qtreewidget

别说谁变了你拦得住时间么 提交于 2020-01-15 11:38:09
问题 Using Python3 and pyside. I have a python dictionary which I want to display as a tree using Qt. I want the values to be editable but not the keys. I have managed to achieve this using setItemWidget as shown in the following example: #!/usr/bin/python3 # -*- coding: utf-8 -*- import sys from PySide import QtGui def data_to_tree(parent, data): if isinstance(data, dict): parent.setFirstColumnSpanned(True) for key,value in data.items(): child = QtGui.QTreeWidgetItem(parent) child.setText(0, key)

Suppress PyQt event temporarily?

主宰稳场 提交于 2020-01-14 10:53:34
问题 I'm populating a branch of a QTreeWidget and then setting the expanded attribute on the parent of the branch to true. The itemExpanded signal fires in response, which is not what I want. Is there a temporary way to suppress or absorb signals during a segment of code? 回答1: You can set blocking of signals using QObject::blockSignals. http://doc.qt.nokia.com/stable/qobject.html#blockSignals bool QObject::blockSignals ( bool block ) If block is true, signals emitted by this object are blocked (i

Suppress PyQt event temporarily?

只谈情不闲聊 提交于 2020-01-14 10:49:07
问题 I'm populating a branch of a QTreeWidget and then setting the expanded attribute on the parent of the branch to true. The itemExpanded signal fires in response, which is not what I want. Is there a temporary way to suppress or absorb signals during a segment of code? 回答1: You can set blocking of signals using QObject::blockSignals. http://doc.qt.nokia.com/stable/qobject.html#blockSignals bool QObject::blockSignals ( bool block ) If block is true, signals emitted by this object are blocked (i

Is it possible to sort numbers in a QTreeWidget column?

大城市里の小女人 提交于 2020-01-12 21:21:35
问题 I have a QTreeWidget with a column filled with some numbers, how can I sort them? If I use setSortingEnabled(true); I can sort correctly only strings, so my column is sorted: 1 10 100 2 20 200 but this is not the thing I want! Suggestions? 回答1: You can sort overriding the < operator and changing sort condiction like this. class TreeWidgetItem : public QTreeWidgetItem { public: TreeWidgetItem(QTreeWidget* parent):QTreeWidgetItem(parent){} private: bool operator<(const QTreeWidgetItem &other

QTreeWidget expand animation on double click

╄→гoц情女王★ 提交于 2020-01-11 09:18:25
问题 I have created a QTreeWidget and set animation to true ( setAnimated(true) ). When I'm clicking on a mark (triangle) at the left of item it expands smoothly, but when I'm double clicking on the item it expands too fast (almost like there is no "animated" flag set). I want smooth animation on double click too. How can I solve this problem? QTreeView calls QTreeViewPrivate::expandOrCollapseItemAtPos on mark click and QTreeViewPrivate::expand on double click, so I have no access to these methods

QTreeView with columns

拥有回忆 提交于 2020-01-05 10:28:47
问题 I have these messages received on the can bus which need to be displayed on a suitable Qt Widget (Please refer attached picture). It seems I can use QTreeView for it. I need to show a tree which contains many messages as shown in attached picture. Each row will contain information about the received message. It should consist of columns : Length Time of receiving Message ID Name of the message Message content and when I expand message it should its different signals. How can I make a

How to delete QTreeWidgetItem

混江龙づ霸主 提交于 2020-01-01 08:52:53
问题 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)

QTreeWidget选中样式

坚强是说给别人听的谎言 提交于 2019-12-26 12:10:17
如何设置QTreeWidget选中样式 概述: 代码: 效果图: over: 概述: 我们在项目开发中总会有一些需求要求我们每步操作可视化效果要明显,今天用到了QTreeWidget控件,一想到控件样式大家首先想到的应该是样式表或者qss文件,今天以上两种方法都不使用,咱们使用更灵活的方式进行设置; 代码: //hover设置鼠标滚动样式 selected设置鼠标选中样式 ui - > treeWidget - > setStyleSheet ( "QTreeView::item:hover{background-color:rgb(0,255,0)}" \ "QTreeView::item:selected{background-color:rgb(255,0,0)}" ) ; 在这里简单说下如果说大家一行代码要是太长我们要养成习惯使用我们强大的续行符,这样不管是谁看代码都显得整洁,也比较易看; 效果图: 鼠标滚动 选中 over: 欢迎大家关注作者在文末评论、点赞、转发以及批评指正! 如果大家有更好的方法或有问题可以在文末评论一起讨论! 共同学习! 共同进步! 来源: CSDN 作者: IT幻想家 链接: https://blog.csdn.net/weixin_43519792/article/details/103706559

QTextEdit as a child node for QTreeWidgetItem?

自闭症网瘾萝莉.ら 提交于 2019-12-25 07:28:26
问题 Is it possible to add a QTextEdit as a child in QTreeWidget? Here is my code we can create a QTreeWidget and add the columns: self.treetext = QtGui.QTreeWidget(self.dockWidgetContents_2) self.treetext.setObjectName(_fromUtf8("treetext")) self.verticalLayout_2.addWidget(self.treetext) self.treetext.setGeometry(QtCore.QRect(20, 10, 261, 241)) item_0 = QtGui.QTreeWidgetItem(self.treetext) item_1 = QtGui.QTreeWidgetItem(item_0) item_1 = QtGui.QTreeWidgetItem(item_0) item_1 = QtGui.QTreeWidgetItem