qtreewidget

Dynamic size of QTreeWidget in PyQt5

我的梦境 提交于 2021-02-20 04:12:36
问题 I got a QTreewidget, which i want to be as small as possible, with probably only one branch. But i want the size to change accordingly to how that expands or collapses. As well as start out with a size that fits the filled part of the widget. I make the QTreewidget by adding QTreeWidgetItems, which got the TreeWidget as parent, and then making QTreeWidgetItems again which got the above QTreeWidgetItem as parent. Right now, it starts like left image, but i want it to start like the right one.

Dynamic size of QTreeWidget in PyQt5

给你一囗甜甜゛ 提交于 2021-02-20 04:12:32
问题 I got a QTreewidget, which i want to be as small as possible, with probably only one branch. But i want the size to change accordingly to how that expands or collapses. As well as start out with a size that fits the filled part of the widget. I make the QTreewidget by adding QTreeWidgetItems, which got the TreeWidget as parent, and then making QTreeWidgetItems again which got the above QTreeWidgetItem as parent. Right now, it starts like left image, but i want it to start like the right one.

Iteration of a QTreeWidget

限于喜欢 提交于 2021-02-11 06:20:32
问题 I have a QTreeWidget that I am using to represent a breakdown structure of data. Basically I plan on using my QTreeWidget in a way to track the population of certain demographics in cities. For example: Males 9,000 - New York 5,000 - D.C. 4,000 Females 10,000 - Nashville 3,000 - San Diego 7,000 Obviously this data is just for example. A few problems I am having with implementing this. I can't figure out how to iterate over the tree. So that every so often I can check if the data has changed.

Iteration of a QTreeWidget

…衆ロ難τιáo~ 提交于 2021-02-11 06:20:18
问题 I have a QTreeWidget that I am using to represent a breakdown structure of data. Basically I plan on using my QTreeWidget in a way to track the population of certain demographics in cities. For example: Males 9,000 - New York 5,000 - D.C. 4,000 Females 10,000 - Nashville 3,000 - San Diego 7,000 Obviously this data is just for example. A few problems I am having with implementing this. I can't figure out how to iterate over the tree. So that every so often I can check if the data has changed.

Drag items between QTreeWidget and QListWidget in PyQt5?

大憨熊 提交于 2021-02-10 07:13:23
问题 I have a QListWidget and a QTreeWidget and I want to be able to drag one or multiple list items around within each one as well as between them. I have the internal drag and drop working, but I'm not sure how to drag between them. When I print event.mimeData().formats() in my code below it says ['application/x-qabstractitemmodeldatalist'] . I am stuck on how to extract the text and index of that item (it should be a QListWidgetItem or QTreeWidgetItem, right?) so I can delete the original from

Drag items between QTreeWidget and QListWidget in PyQt5?

拈花ヽ惹草 提交于 2021-02-10 07:09:20
问题 I have a QListWidget and a QTreeWidget and I want to be able to drag one or multiple list items around within each one as well as between them. I have the internal drag and drop working, but I'm not sure how to drag between them. When I print event.mimeData().formats() in my code below it says ['application/x-qabstractitemmodeldatalist'] . I am stuck on how to extract the text and index of that item (it should be a QListWidgetItem or QTreeWidgetItem, right?) so I can delete the original from

Determine visible size of a QTreeWidget column

℡╲_俬逩灬. 提交于 2021-02-08 08:44:21
问题 I need to determine the VISIBLE width of a column within a QTreeWidget. I'll explain my problem with a small example. A QTreeWidget defines three columns with the fixed width of col 1=200 px, col 2=100 px and col 3=300 px. The widget itself has a ( resizeable ) width of 350. The width of all colums ( 200 + 100 + 300 = 600 ) exeeds the with of the widget, so a scrollbar is shown. For some special calculation I need to know the visible width of the third column: Case A would be quite easy, I

QTreeWidget insert between two items using drag and drop

喜欢而已 提交于 2020-12-12 11:41:07
问题 I have a QTreeWidget which I have setup like so... ModelTreeWidget::ModelTreeWidget(QWidget *parent):QTreeWidget(parent), mpModelStruct(nullptr), mpModeldragging(nullptr), mpBufferModel(nullptr), mpModelCurrent(nullptr) { setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed); setColumnCount(1); setSelectionMode(QAbstractItemView::SingleSelection); setDragEnabled(true); viewport()->setAcceptDrops(true); setDropIndicatorShown(true); setDragDropMode

Showing filesystem in QTreeWidget

折月煮酒 提交于 2020-07-19 07:51:10
问题 I have a simple Question. I want to show my filesystem in a QTreeWidget just like an common file explorer. How can i achieve that? I guess searching through all files and add them manual is not the approach to chose, right? 回答1: use QDirModel and QTreeView instead of QTreeWidget, here is a code snippet: QDirModel *model = new QDirModel; QTreeView *tree = new QTreeView(splitter); tree->setModel(model); tree->setRootIndex(model->index("C:\\")); 来源: https://stackoverflow.com/questions/20995257