qlistwidget

Qt: List of (custom) QWidgets without performance problems

被刻印的时光 ゝ 提交于 2019-12-11 09:53:10
问题 I'm right now creating an Qt-application and have following problem: I designed a custom QWidget with some labels and checkboxes. The application should now show a list of the custom QWidgets. I tried the QListWidget but is very slow for my use case. I want to add over 6000 elements of my custom QWidget. If I create these instances of the element and add it to the QListWidget the application will crashed. Which is the best approach for my issue? Thanks a lot! 回答1: As others have noted,

How to know if QListWidgetItem is hidden by scroll?

删除回忆录丶 提交于 2019-12-11 06:43:12
问题 Well, i'm newbie in Qt and i have a problem. I have a QListWidget in my UI with 7 items, just 4 items are showed and the other are showed after to use scrollbar. I want to show a arrow image above and below QListWidet than will show than there are more items to scroll. Ok, i can to see if a item is hidden, but just if it is hidden by setHidden() function. And when is it hidden by scroll? Can i see this in run time? Because the item is there, but scroll is hiding it, right? I searched some

How to customize QListWidget with different highlight bar and spacing

喜欢而已 提交于 2019-12-10 23:17:46
问题 I'm working on an application that needs to have a menu on the left side of the screen containing multiple items (text). The only items I want to be visible are the actual text and the highlight bar. I would also like to modify the highlight bar so that: a. I can animate it, and slide it from one selection to the next b. I can use a custom pixmap with rounded corners instead of the default highlight color I've tried using a QListWidget and stylesheets and had some success, but I don't believe

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

时间秒杀一切 提交于 2019-12-10 11:33:32
问题 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

How to Drag and Drop from ListWidget onto ComboBox

随声附和 提交于 2019-12-10 10:48:50
问题 The goal is to be able to drag-and-drop ListWidget items onto the comboBox. The dropped items should be added to the combobox. Ideally we want to avoid any tricks with reading listWidget's .currentItem() or .selectedItems() and etc... Ideas? from PyQt4 import QtGui, QtCore import sys, os class MyClass(object): def __init__(self): super(MyClass, self).__init__() self.name=None def setName(self, arg): self.name=arg def getName(self): return self.name class DropableComboBox(QtGui.QComboBox): def

QListWidget change part color of text

喜欢而已 提交于 2019-12-09 22:33:04
问题 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

Can I store some user data in every item of a QListWidget?

冷暖自知 提交于 2019-12-09 15:05:00
问题 I want to store some filenames in a QListWidget. I need to have the full file paths, but I only want to show the base filename. I probably could store the full filename in the tooltip for each item, but I'd rather not have tooltips for the list items. 回答1: You can set data for and get data from each QListWidgetItem. See QListWidgetItem::setData() and QListWidgetItem::data(). Data can be set for different roles. Use Qt::UserRole, which is "The first role that can be used for application

Remove selected items from listWidget

此生再无相见时 提交于 2019-12-09 14:06:50
问题 How to remove selected items from qlistWidget . I have tried write the following code, but does not work. QList<QListWidgetItem*> items = ui->listWidget->selectedItems(); foreach(QListWidgetItem item, items){ ui->listWidget->removeItemWidget(item); } Now, how to remove the items that I selected from the qlistWidget ? 回答1: One way to remove item from QListWidget is to use QListWidget::takeItem which removes and returns the item : QList<QListWidgetItem*> items = ui->listWidget->selectedItems();

PyQt4 : is there any signal related to scrollbar?

非 Y 不嫁゛ 提交于 2019-12-08 08:31:29
I plan to create a two listWidget and they have same amount of list. So, when a listWidget scroll up and down, another one also travel it's list. But, I can't find related signal. Did I miss something? You need to connect the valueChanged signals of one scrollbar to the setValue slot of the other scrollbar (and vice versa). At first glance, this might seem dangerously recursive, but Qt seems to handle it without any problem, as this example shows: from PyQt4 import QtGui, QtCore class Window(QtGui.QWidget): def __init__(self): QtGui.QWidget.__init__(self) self.listA = QtGui.QListWidget(self)

Manipulating QT Ui with different source files

天大地大妈咪最大 提交于 2019-12-08 07:26: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