qlistwidget

How to list items as groups in QListWidget

流过昼夜 提交于 2019-12-08 05:36:06
问题 Is it possible to to set QListWidget items in groups. For example if i am adding the content of a folder to listwidget. i want to show all folders in folders group and files in files group. Like in the image below. Is it possible. 回答1: Create for each group a list with all items, sort the list by an arbitrary property and add the item groups in desired order to listwidget. Between or in front of the groups a delimiter or title can be added, the groups can get different styles. e.g. your files

How to list items as groups in QListWidget

僤鯓⒐⒋嵵緔 提交于 2019-12-07 04:55:27
Is it possible to to set QListWidget items in groups. For example if i am adding the content of a folder to listwidget. i want to show all folders in folders group and files in files group. Like in the image below. Is it possible. Create for each group a list with all items, sort the list by an arbitrary property and add the item groups in desired order to listwidget. Between or in front of the groups a delimiter or title can be added, the groups can get different styles. e.g. your files/folders groups: files.sort() # list of files folders.sort() # list of folders for f in folders: item =

QListWidget: More icons on one row

亡梦爱人 提交于 2019-12-06 15:57:47
For my bachelor thesis I'm programming an Role Playing Game maker. I'm making use of tilesets (left picture below). I load such an image in my project and split it in small square blocks (tiles). Now, I load these in a QListWidget, but I would like the QListWidget to show as many tiles in a row as there are in the image (for example: the image below contains 8 tiles/row, but in my program, the QListWidget only shows 6 tiles per row). I have tried to work with layouts, but these don't seem to work. Any idea on how to let the QListWidget display a custom amount of items per row? I like to work

Manipulating QT Ui with different source files

﹥>﹥吖頭↗ 提交于 2019-12-06 15:57:10
I searched for some hours now but I'm not able to find a solution. My setup is as follows: Widget.h Widget.cpp Widget.ui Function.h Function.cpp I wrote a function in my Function.cpp which adds some entries to a QListWidget in my Widget.ui. It's just a trial and error project: I already included widget.h and ui_widget.h so I can access the classes. The Widget is the QWidget template which you can create with the QtDesigner. In there is a QListWidget and a QButton. If I click the QButton then it calls the function in Function.cpp which will add an item to the QListWidget. Do i have to write a

How to change (remove) selection/active color of QListWidget

倖福魔咒の 提交于 2019-12-06 07:16:40
In my QListWidget , there are some items that have non-default background color, I set them like so inside the custom QListWidget class: item->setBackgroundColor(qcolor); // item is of type QListWidgetItem* Those non-default colors that I set are distorted by the QListWidget 's selection color. See an example: Items three and four are supposed to be the same color, but they are not since the item four is selected, and thus the result color is a summation of original color and QListWidget 's selection (active item?) color. My question is how to edit or remove that selection color? I tried

Drag'N'Drop custom widget items between QListWidgets

假装没事ソ 提交于 2019-12-06 00:12:24
i am currently working on a Python program, where i want to move items from one QListWidget to another with Drag and Drop. i read this thread , and implemented the Drag and Drop as described. It works with standard QListWidgetItems. The Problem is, i wanna do this custom widgets inside the QListWidgetItems, as described here , to store an icon and several lines into 1 QListWidgetItem. So when i now drag and drop an item into another list, it is empty, because it seems just to move/copy the QListWidgetItem without its ItemWidget. Heres an example code: from PyQt4 import QtGui, QtCore import sys

Multiple Selection QTreeWidget

此生再无相见时 提交于 2019-12-05 14:05:16
问题 Does anyone know if its possible to select multiple items on a QTreeWidget and how to go about enabling the multiple selection? All the items I want to be selectable are top level QTreeWidgetItems and all their children are set to be disabled (i.e QTreeWidgetItem.setDisabled(True) ) 回答1: It is, you'll want to call setSelectionMode during init to enable QAbstractItemView::MultiSelection. QTreeView/QTreeWidget inherit QAbstractItemView, so it is available. Then to disable the items, just hook

Can't change state of checkable QListViewItem with custom widget

☆樱花仙子☆ 提交于 2019-12-05 13:06:43
I have a QListWidget where I want to add a bunch of items with a custom widget: listWidget = QListWidget() item = QListWidgetItem() item.setFlags(item.flags() | Qt.ItemIsUserCheckable) item.setCheckState(Qt.Unchecked) listWidget.addItem(item) widget = MyLabelAndPushButton() item.setSizeHint(widget.sizeHint()) listWidget.setItemWidget(item, widget) As the name suggests MyLabelAndPushButton is just a widget containing a QLabel and a QPushButton in a layout. The problem is that I can not use the checkbox that appears in the listwidget next to the widget. It looks completely normal, but nothing

Qt drag and drop between two QListWidget

a 夏天 提交于 2019-12-05 01:10:37
I've two QListWidget (list1 and list2) list1 should be able to receive items from list2 list1 should be able to be reorganized with an internal drag and drop list2 should be able to receive items from list1 list1->setSelectionMode(QAbstractItemView::SingleSelection); list1->setDragEnabled(true); list1->setDragDropMode(QAbstractItemView::DragDrop); list1->viewport()->setAcceptDrops(true); list1->setDropIndicatorShown(true); ulist2->setSelectionMode(QAbstractItemView::SingleSelection); list2->setDragEnabled(true); list2->setDragDropMode(QAbstractItemView::InternalMove); list2->viewport()-

QListWidget change part color of text

☆樱花仙子☆ 提交于 2019-12-04 18:00:25
Click Here to open the Sample Picture, the red Arrow is what I want, But the output just show all the code and didn't work just like the Blue Arrow does I try use < font color = red >...< /font > || < span >...< /span > in QListWidget, but There didn't have any Effect What I want is some thing like: item1 <font color=red>apple</font> ("item1" black, "apple" will output as red color) item2 <font color=green>durian</font> (durian will output as green color) Can Anyone help? Ps: Accually what I really want is the picture below: When I type the word "cola", the list of QListwidget will Highlight