qlistwidget

How to center QPixmap while Painting it inside QItemDelegate of QListWidget

两盒软妹~` 提交于 2019-12-25 18:48:12
问题 I'm painting a QPixmap inside the QItemDelegate of QListWidget. Each QListWidgetItem is of different dimensions. Inside the void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) function of QItemDelegate, I want to paint QPixmap with center Alignment inside the QListWidgetItem. option.rect() gives the geometry of the item with which I can calculate the center position and paint accordingly, but I want to know the better approach for this alignment.Can

pyqt adding a widget to a QListWidget

◇◆丶佛笑我妖孽 提交于 2019-12-25 04:24:24
问题 hi i created 2 files from qtdesigner and i created a new file with a class where i want to use these UIs that i created. this is the file creating the QListWidget from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: _fromUtf8 = lambda s: s class Ui_main_Dialog_lists(object): def setupUi(self, main_Dialog_lists): main_Dialog_lists.setObjectName(_fromUtf8("main_Dialog_lists")) main_Dialog_lists.resize(590, 521) self.main_verticalLayout = QtGui

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

谁说我不能喝 提交于 2019-12-25 00:53:07
问题 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()"

Pyqt5 refresh/update QListWidget based on event in custom widget?

旧街凉风 提交于 2019-12-24 10:22:33
问题 I am trying to update/refresh a QListWidget after I click a button in a CustomFormWidget . What I am trying to do is when I click the button in a CustomFormWidget , it updates the class variable data in the ParentWid and then rebuilds/updated/refreshes ParentWid.ui.listWidget . Where and how should I add this logic. Should I add to my CustomFormWidget.on_click method or should my logic be set in the ParentWid ? So far my code looks like: from PyQt5 import QtCore, QtGui, QtWidgets class

How to properly add strings to QListWidgets?

懵懂的女人 提交于 2019-12-24 05:16:13
问题 In the following code the method exec(const char *cmd) runs a bash script and returns the output as a vector of strings. The intent is to create a QListWidgetItem out of each of those strings and add them to a QListWidget on a little GUI that I have created, but the QListWidgetItem s are not created successfully. I always seem to be required to use a const char* to create either a QString or QListWidgetItem , it will not allow me to create one using a string variable. You can see what I am

How to filter image files from selected directory (which is inside listWidget)

左心房为你撑大大i 提交于 2019-12-24 01:38:08
问题 I have a problem that I don't know how to filter images from a selected directory. I usually use directory.setNameFilters({"*.png", "*.jpg"}); but in this case I can't use that because I need to use the selected directory inside a listWidget . I use signal and slot functions. I mean if I click a directory which is inside a listWidget , the images inside this directory will be displayed in another listWidget . If I click another directory it will do the same function. Please take a look my

Qt: QListWidget separator line between items?

喜夏-厌秋 提交于 2019-12-23 15:26:31
问题 I can't find any way to put a line between items in my list. Am I missing something? 回答1: A style sheet would be easiest, for example: myListWidget->setStyleSheet( "QListWidget::item { border-bottom: 1px solid black; }" ); You'll want to look at some of the style sheet documentation 来源: https://stackoverflow.com/questions/7780411/qt-qlistwidget-separator-line-between-items

How to set minimum height of QListWidgetItem?

允我心安 提交于 2019-12-23 07:33:27
问题 How can I set the minimum height of a QListWidgetItem ? I'm using QListWidget::setItemWidget() with a customized widget, and although I explicitly declared minimum height of my customized widget, those QListWidgetItem s still have a pretty low height attribute. 回答1: Use setSizeHint on the items. void QListWidgetItem::setSizeHint ( const QSize & size ) This is the right method for telling the delegate how much screen it must preserve for the item. Look at http://qt-project.org/doc/qt-4.8

PyQt4 : is there any signal related to scrollbar?

烂漫一生 提交于 2019-12-23 03:58:17
问题 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? 回答1: 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

QListWidget: More icons on one row

可紊 提交于 2019-12-23 03:04:30
问题 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