qtreewidget

Invoking context menu in QTreeWidget

时光总嘲笑我的痴心妄想 提交于 2019-12-12 09:42:56
问题 I would like to popup a menu, when user clicks on an object in QTreeWidgetItem. I though about catching signal contextMenuRequested from QWidget and then retrieving index from the view using itemAt. But this doesn't seem very pretty. Is there any easier way to be able to call a menu on an item inside a view? 回答1: Write your own custom ItemDelegate and handle the click event in QAbstractItemDelegate::editorEvent . You can retreive the data in the cell from the QModelIndex. In C++ it would look

QTreeWidget and QFileSystemModel

[亡魂溺海] 提交于 2019-12-11 20:25:29
问题 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

What can block mousePressEvent or Event Filter Mouse Click Events?

落爺英雄遲暮 提交于 2019-12-11 16:22:33
问题 I can't seem to get any mouse clicks in a QTreeWidget. I have tried... ...overriding mousePressEvent, but it never runs at all. Not even to log a message. ...using an event filer. It works for everything but mouse clicks. ...using delegates. Their editor events work fine, but only when over an item, which isn't enough ...making sure everything is being added to layouts. I used QTCreator and the output is using layout.addWidget(). I am also adding the widget instance to a layout in the main

error: QT 5.0 QTreeWidget include not found

五迷三道 提交于 2019-12-11 13:02:34
问题 In manual for QTreeWidget it states that we have to: include however when I do that I get error: d:** * ** * *** : error: C1083: Cannot open include file: 'QTreeWidget': No such file or directory However #include gets found. Where does it go wrong here? Thanks! 回答1: Add QT += widgets (to link with the widgets module) into your .pro file, then run qmake and then build your project. 来源: https://stackoverflow.com/questions/16791844/error-qt-5-0-qtreewidget-include-not-found

Set delegate for QTreeWidget header

前提是你 提交于 2019-12-11 07:57:27
问题 I need to set delegate for QTreeWidget header or make it working with HTML tags using other ways. I set a delegate for QTreeWidget items using ui->tree->setItemDelegate(delegate); and it works. But setting a delegate to the header does not work : ui->tree->header()->setItemDelegate(delegate); 回答1: It won't work and it's documented here http://qt-project.org/doc/qt-4.8/qheaderview.html#appearance Note: Each header renders the data for each section itself, and does not rely on a delegate. As a

Inserting a child Item into a row of QTreeWidgetItems

孤人 提交于 2019-12-11 06:05:59
问题 I have setup my QTreeWidget such that each cell is filled with comboboxes, however I would like to create a text edit widget next to the selected combobox (or overwrite the existing combobox), depending on which combobox item the user has selected. I figured I could do this by adding the comboboxes parent as a property when its initially setup and then upon interaction with the combobox simply use setItemWidget to put a text edit Item in column after the selected combobox (using the same

PyQt validity check on QTreeWidgetItem

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 05:34:44
问题 I'm building a QTreeWidget where I'm implementing adding new item and renaming functionality. I'd like to check the validity of the new name given by user, including: the name can only contain a list of valid characters. This is achieved already by adding a QRegExpValidator to a subclassed QItemDelegate , and assigning the new delegate to the QTreeWidget . the name can't conflict with its siblings. This I don't know now to achieve. Here is my current attempt: import sys from PyQt5.QtWidgets

Developing pyqt4 tree widget

非 Y 不嫁゛ 提交于 2019-12-11 05:21:51
问题 i need to write a tree?, in pyqt. It looks like this: Clients(this is text) Type A (this is a Clients child and has a checkbox) Type B (this is a Clients child and has a checkbox) Vendors(this is text) Mary (this is a Vendors child and has a checkbox) Arnold (this is a Vendors child and has a checkbox) Time Period Init(this is a Time Period child, and would be a calendarWidget for date selection) End (this is a Time Period child, and would be a calendarWidget for date selection) What would

QTreeView vs setIndexWidget

你离开我真会死。 提交于 2019-12-11 02:02:47
问题 I am using QStandardItemModel with QStandardItem's. I don't want to write my own model and any delegates. I just want to have tree of checkboxes with QComboBox'es in second column... m_model->setColumnCount(2); for (int i = 0; i < sectionCount; i++) { QStandardItem * section = new QStandardItem(tr("Section %1").arg(i+1)); section->setCheckable(true); section->setCheckState(Qt::Checked); for (int j = 0; j < itemsCount; j++) { QStandardItem * item = new QStandardItem(tr("Item %1").arg(j+1));

Remove space from QLabel in a QTreeWidget

冷暖自知 提交于 2019-12-10 21:28:03
问题 I've added QLabel widgets to my QTreeWidget to work around the word wrapping issue in QTreeWidget. (see how to word wrap a QTreeWidgetItem). The QLabel widgets appear to have spacing around the text which for some reason disappears when the text wraps. It also does not show up when the Label text is blank. I tried setting setContentsMargin(0,0,0,0) on the QLabel but that didn't work. I also tried setStyleSheet("border: 0px; margin: 0px; padding: 0px;") which also didn't help. Screenshot: You