qlistwidget

How to create a list of checkboxes

此生再无相见时 提交于 2019-12-02 03:52:58
问题 I'm trying to read in an xml file and populate a QListWidget with some of its contents. Each entry should have a checkbox. In Qt Designer I created the list and added an item that has a checkbox by adding the item to the listWidget, then right clicking on it and selecting Edit Items > Properties > Set Flags to UserCheckable. So i can do it manually. But when I read in the xml file to populate the ListWidget I can't make these items checkable. import xml.etree.ElementTree as et xml_file = os

Detecting if an item is clicked at at some row in a QlistWidget

╄→尐↘猪︶ㄣ 提交于 2019-12-02 01:35:43
I Have been given this simple task , I have this list where i instert items whenever ok is clicked,void Form::ok() handle that event is supposed to add new list items to the list. Now what am not able to do is to detect the if an item is clicked at at some row then do something according to that, this is my code.. #include "form1.h" #include "form.h" #include "ui_form.h" #include "ui_form1.h" #include<QScrollArea> #include<QScrollBar> //#include <QgeoPositioninfo.h> Form::Form(QWidget *parent) : QWidget(parent), ui(new Ui::Form) { ui->setupUi(this); } Form::~Form() { delete ui; } void Form::ok

How to get the checked items listed in a Qt QListWidget

99封情书 提交于 2019-12-01 21:54:39
I've populated a QListWidget with a list of items and added a check box leaving everything unchecked. for td in root.iter('testdata'): test_data = td.get('ins') item = QtGui.QListWidgetItem(test_data, self.listWidgetLabels) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) item.setCheckState(QtCore.Qt.Unchecked) The user then clicks a few of the items in the QListItem and clicks a 'Generate File' button on the gui. self.pushButtonGenerateFile.clicked.connect(self.generate_file) I want to get a list of all the checked QListItems. def generate_driver(self): test = self.listWidgetLabels

How to update QListWidget

无人久伴 提交于 2019-12-01 12:56:51
How to update QLIstWidget to show items as when when it is added. Like i am adding 100 QListWidgetItems to QListWidget in a loop. All these 100 items are visible only after loop is completed. But i want to know if is it possible to show item as and when the item is added. I tried self.ListWidget.setUpdatesEnabled(True) but no luck. Any help is appreciated. you can repaint the listwidget in the loop: def insertItem(self): for i in range(1,100): self.listWidget.addItem(str(i)) self.listWidget.repaint() with QTimer you can control the delay between 2 items. Edit: Perhaps i didn't understand your

How to select a QListWidgetItem when click on a widget [child] inside it

a 夏天 提交于 2019-12-01 11:22:53
I created a QListWidget... The QListWidgetItem composes of a QPushButton and QLineEdit aligned inside QHBoxLayout... The QPushButton within the QListWidgetItem is linked to function that should delete the current QListWidgetItem from the QListWidget when it's clicked... I am using the method " takeItem() " passing to it the output of the method " currentRow() " to delete the entry... The problem is when I click on the delete button the QListWidgetItem is not selected, hence the "currentRow()" returns nothing... My question: How can I make the QListWidgetItem entry get selected once I hit the

How to update QListWidget

本小妞迷上赌 提交于 2019-12-01 11:21:41
问题 How to update QLIstWidget to show items as when when it is added. Like i am adding 100 QListWidgetItems to QListWidget in a loop. All these 100 items are visible only after loop is completed. But i want to know if is it possible to show item as and when the item is added. I tried self.ListWidget.setUpdatesEnabled(True) but no luck. Any help is appreciated. 回答1: you can repaint the listwidget in the loop: def insertItem(self): for i in range(1,100): self.listWidget.addItem(str(i)) self

How to select a QListWidgetItem when click on a widget [child] inside it

杀马特。学长 韩版系。学妹 提交于 2019-12-01 08:17:54
问题 I created a QListWidget... The QListWidgetItem composes of a QPushButton and QLineEdit aligned inside QHBoxLayout... The QPushButton within the QListWidgetItem is linked to function that should delete the current QListWidgetItem from the QListWidget when it's clicked... I am using the method " takeItem() " passing to it the output of the method " currentRow() " to delete the entry... The problem is when I click on the delete button the QListWidgetItem is not selected, hence the "currentRow()"

PyQt4 - Remove Item Widget from QListWidget

断了今生、忘了曾经 提交于 2019-12-01 01:26:52
问题 I have a QListWidget and I need to remove some items. From what I've researched, this is a generally unpleasant thing to do. I've read a tonne of solutions, but none are applicable to my specific scenario. At the moment, I only have the actual Item Widgets to deal with; not their values or index. This is because I obtain the items (needed to be removed) via .selectedItems() . Here's the code: ItemSelect = list(self.ListDialog.ContentList.selectedItems()) for x in range (0, len(ItemSelect)):

Qt - signal for when QListWidget row is edited?

拟墨画扇 提交于 2019-11-30 20:03:28
问题 I am working in Qt4.7, and I have a QListWidget in my dialog. I have a QString that needs to match the current text in the row of this widget (the individual rows are editable). Looking at the signals associated with QListWidget, there seem to be signals for when a different index is selected but none for when the text of a the currently selected row changes. I thought currentTextChanged(QString) would do it, but it didn't. I also thought to try to connect each individual row to something,

Qt/C++: Signal for when a QListWidgetItem is checked?

a 夏天 提交于 2019-11-30 17:42:29
In my form I have a QListWidget which contains checkable QListWidgetItems . I'm looking for a way to capture the event of a QListWidgetItem being checked/unchecked. I don't see any such signal existing for this but maybe I'm wrong. What I'm currently doing is using the QListWidget::itemClicked() signal and checking the checkState of the QListWidgetItem , but this isn't what I want because this event happens any time the item is clicked, not just went the checkmark is toggled. Can anyone give some assistance? Thanks! jkerian Apparently no such signal is provided, your best bet is to use