qtreewidgetitem

Is it possible to create a signal for when a QTreeWidgetItem checkbox is toggled?

左心房为你撑大大i 提交于 2019-12-08 15:33:13
问题 I've created a checkbox that's also a QTreeWidgetItem using the code below. //Populate list QTreeWidgetItem *program = createCheckedTreeItem(QString::fromStdString(itr->first), true); treePrograms->addTopLevelItem(program); QTreeWidgetItem* ConfigDialog::createCheckedTreeItem(QString name,bool checkBoxState) { QTreeWidgetItem *item = new QTreeWidgetItem(QStringList(name)); item->setFlags(item->flags()|Qt::ItemIsUserCheckable); if (checkBoxState) { item->setCheckState(0,Qt::Unchecked); } else

How to get the number of items of a QTreeWidget

拜拜、爱过 提交于 2019-12-05 14:56:16
I have created a QTreeWidget, I'm trying to list all the items displayed. I do not want to go inside the items if the item have child but not expanded. It's really getting the number of Items I can see in the tree. I have tried : for( int i = 0; i < MyTreeWidget->topLevelItemCount(); ++i ) { QTreeWidgetItem *item = MyTreeWidget->topLevelItem(i); ... but this is giving me only the topLevelItem and I want all I can see. In the example, I should be able to count 14 items You can write a recursive function that will run over the hierarchy and count all visible items. For example: int treeCount

Is it possible to sort numbers in a QTreeWidget column?

杀马特。学长 韩版系。学妹 提交于 2019-12-04 05:49:51
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? 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)const { int column = treeWidget()->sortColumn(); return text(column).toLower() < other.text(column).toLower();

PyQt Tree Widget, adding check boxes for dynamic removal

北城以北 提交于 2019-11-30 03:01:23
I am attempting to create a tree widget that will essentially allow the user to view various breakdowns of data and have the option to delete certain items. In order to do this I want to have check boxes associated with each top level item and each child so the user can select which top level items (and thus all the children of that top level item) to delete. Or which specific children to delete. To give you a better idea I've created an example where [x] represents a checked check box and [ ] represents an empty checkbox: >Beverages Allowed in Stadium [ ] Soda [ ] Water [ ] Tea [ ] Spirits [X

PyQt Tree Widget, adding check boxes for dynamic removal

为君一笑 提交于 2019-11-29 00:10:40
问题 I am attempting to create a tree widget that will essentially allow the user to view various breakdowns of data and have the option to delete certain items. In order to do this I want to have check boxes associated with each top level item and each child so the user can select which top level items (and thus all the children of that top level item) to delete. Or which specific children to delete. To give you a better idea I've created an example where [x] represents a checked check box and [

Making only one column of a QTreeWidgetItem editable

自古美人都是妖i 提交于 2019-11-27 22:44:32
I have a QTreeWidgetItem with two columns of data, is there any way to make only the second column editable? When I do the following: QTreeWidgetItem* item = new QTreeWidgetItem(); item->setFlags(item->flags() | Qt::ItemIsEditable); all columns become editable. Looks like you will have to forgo using QTreeWidget and QTreeWidgetItem and go with QTreeView and QAbstractItemModel . The "Widget" classes are convenience classes that are concrete implementations of the more abstract but more flexible versions. QAbstractItemModel has a call flags(QModelIndex index) where you would return the