qlistwidget

QListWidget and Multiple Selection

杀马特。学长 韩版系。学妹 提交于 2019-11-30 17:26:30
I have a regular QListWidget with couple of signals and slots hookedup. Everything works as I expect. I can update, retrieve, clear etc. But the UI wont support multiple selections. How do I 'enable' multiple selections for QListWidget ? My limited experience with PyQt tells me I need to create a custom QListWidget by subclassing .. but what next? Google gave me C++ answers but I'm looking for Python http://www.qtforum.org/article/26320/qlistwidget-multiple-selection.html http://www.qtcentre.org/threads/11721-QListWidget-multi-selection Unfortunately I can't help with the Python specific

PyQt: How to get most of QListWidget

余生长醉 提交于 2019-11-30 14:20:33
The code builds a dialog box with a single QListWidget and a single QPushButton . Clicking the button adds a single List Item. Right-click on a List Item brings up a right-click menu with "Remove Item" command available. Choosing "Remove Item" command removes a List Item from List Widget. Would be interesting to see how the following ListWidgets ops could be implemented: Ability to move the list items up and down (re-arrange). Being able to multi-select and multi-delete list items. A better more robust list-item sorting. Example: import sys, os from PyQt4 import QtCore, QtGui class

Storing pointers using QListWidgetItem::setData

对着背影说爱祢 提交于 2019-11-30 12:38:40
I have a QListWidget of calendars. Each QListWidgetItem is logically associated with an instance of Calendar , which is a class that belongs to the Model side of the application. Can I store this association in the form of a pointer using QListWidgetItem::setData ? When I attempt to do this, I get the following error: error: 'QVariant::QVariant(void*)' is private There is another constructor for void*: QVariant::QVariant(int typeOrUserType, const void * copy) where you should pass an unique integer to represent the pointer type. But as stated by the documentation, you could declare your

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

与世无争的帅哥 提交于 2019-11-30 01:18:07
问题 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

QListWidget and Multiple Selection

此生再无相见时 提交于 2019-11-30 01:06:01
问题 I have a regular QListWidget with couple of signals and slots hookedup. Everything works as I expect. I can update, retrieve, clear etc. But the UI wont support multiple selections. How do I 'enable' multiple selections for QListWidget ? My limited experience with PyQt tells me I need to create a custom QListWidget by subclassing .. but what next? Google gave me C++ answers but I'm looking for Python http://www.qtforum.org/article/26320/qlistwidget-multiple-selection.html http://www.qtcentre

关于QFrame继承于QWidget 和 QListWidget也继承于QWidget

爷,独闯天下 提交于 2019-11-30 00:26:31
Reimplemented Protected Functions(重新实现的受保护的方法) 在我测试关于drag and drop (拖放事件)的时候,我发现同样给QFrame和QListWidget添加三个Qlabel组件,QFrame和QListWidget对于鼠标响应事件的处理机制是不同的,后面翻看Qt源代码之后发现: QFrame直接继承于QWidget,对于event(QEvent* e)实现了一次重载。 而QListWidget通过多次继承之后继承于QWidget,在此期间event(QEvent* e)实现了多次重载,具体是做什么没有去细看,可以想象QFrame和QListWidget对于事件的处理是有差别的。 自己做的测试是 :把三个QLabel分别放进QFrame和QListWidget之后对QLabel使用鼠标点击,QFrame和QListWidget都重新实现了mousePressEvent(QMousePressEvent* event),但是只有QFrame对鼠标按下事件做出响应,QListWidget没有对鼠标按下事件做出响应。 来源: https://blog.csdn.net/n__o_more/article/details/100980329

PyQt: How to get most of QListWidget

纵饮孤独 提交于 2019-11-29 20:04:02
问题 The code builds a dialog box with a single QListWidget and a single QPushButton . Clicking the button adds a single List Item. Right-click on a List Item brings up a right-click menu with "Remove Item" command available. Choosing "Remove Item" command removes a List Item from List Widget. Would be interesting to see how the following ListWidgets ops could be implemented: Ability to move the list items up and down (re-arrange). Being able to multi-select and multi-delete list items. A better

Storing pointers using QListWidgetItem::setData

こ雲淡風輕ζ 提交于 2019-11-29 18:18:54
问题 I have a QListWidget of calendars. Each QListWidgetItem is logically associated with an instance of Calendar , which is a class that belongs to the Model side of the application. Can I store this association in the form of a pointer using QListWidgetItem::setData ? When I attempt to do this, I get the following error: error: 'QVariant::QVariant(void*)' is private 回答1: There is another constructor for void*: QVariant::QVariant(int typeOrUserType, const void * copy) where you should pass an

How to Drag and Drop from One QListWidget to Another

白昼怎懂夜的黑 提交于 2019-11-27 21:37:59
There are two QListWIdgets sitting in a same dialog window. The DragDrop functionality has been enabled for both. If I drag and drop a file to any of two ListWidges the program recognizes it and prints out the list of the files dropped. But aside from drag and dropping files I would like to be able to drag and drop the List widget Items from one to another. If I drag the ListItems the drag and drop event is triggered. But it is not able to recognize what Items were dropped onto the widget. The example code is below. The goal is to drag-drop the list items from one ListWidget to another. import

QListView/QListWidget with custom items and custom item widgets

僤鯓⒐⒋嵵緔 提交于 2019-11-26 21:51:28
I'm writing a PyQt application and am having some trouble creating a custom list view. I'd like the list to contain arbitrary widgets (one custom widget in particular). How would I go about this? It seems that the alternative would be to create a table or grid view wrapped in a scrollbar. However, I'd like to be able to take advantage of the model/view approach as well as the nesting (tree-view) support the built-ins handle. To clarify, the custom widgets are interactive (contain buttons), so the solution requires more than painting a widget. Idan K I think you need to subclass QItemDelegate .