qlistview

Simple way to get all visible items in the QListView

青春壹個敷衍的年華 提交于 2021-02-19 02:52:49
问题 I am trying to develop an image gallery application using Qt Framework. The application loads all the images from the selected folder and those images are displayed using QListView control. But now i want to reduce the memory consumption by loading only the images that are visible to user. Since there is no direct function to get all the visible items in the view, i am not able to achieve this. 回答1: You can get the visible items of a list view using the indexAt function. For more details and

how to change Qt qListView Icon selection highlight

我只是一个虾纸丫 提交于 2021-02-18 11:17:06
问题 When using qlistview in icon mode I need to completely remove the hilighting when a icon is selected. Using the code below the text under the icon is no longer highlighted but I still get blue color over the icon when selected QString stylesheet = ""; stylesheet += "QListView::item:alternate {background-image: transparent; background-color: transparent;}"; stylesheet += "QListView::item:selected {background-image: transparent; background-color: transparent;padding: 0px;color: black;}";

PyQt4 filter by text on a QListView using setRowHidden

烈酒焚心 提交于 2021-02-16 15:09:25
问题 I have a dialog which looks like this: That dialog has the following code connected to the filter button: class Dialog(QtGui.QDialog, addWin.Ui_Dialog): ... self.list = QListView() self.filter.clicked.connect(self.filterClicked) ... def filterClicked(self): filter_text = str(self.lineEdit.text()).lower() for row in range(self.model.rowCount()): if filter_text in str(self.model.item(row).text()).lower(): self.list.setRowHidden(row, True) else: self.list.setRowHidden(row, False) However, when I

PyQt4 filter by text on a QListView using setRowHidden

∥☆過路亽.° 提交于 2021-02-16 15:08:58
问题 I have a dialog which looks like this: That dialog has the following code connected to the filter button: class Dialog(QtGui.QDialog, addWin.Ui_Dialog): ... self.list = QListView() self.filter.clicked.connect(self.filterClicked) ... def filterClicked(self): filter_text = str(self.lineEdit.text()).lower() for row in range(self.model.rowCount()): if filter_text in str(self.model.item(row).text()).lower(): self.list.setRowHidden(row, True) else: self.list.setRowHidden(row, False) However, when I

Adding items to QlistView

↘锁芯ラ 提交于 2021-02-04 14:58:08
问题 I'm using pyqt4 with python 2.7 and I have a list view widget that I can't add items to it # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'add_category.ui' # # Created: Mon Mar 19 23:22:30 2018 # by: PyQt4 UI code generator 4.10 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fromUtf8(s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def

Show Last element in QListView

Deadly 提交于 2021-01-29 10:49:29
问题 It sounds trivial, but I could not find the function to show the last added element in a QListView. It works with a model // Create model model = new QStringListModel(this); // Make data QStringList List; // Populate our model model->setStringList(List); // Glue model and view together listView->setModel(model); Elements are added with void WidgetMessageList::addString(const QString & message) { if(model->insertRow(model->rowCount())) { QModelIndex index = model->index(model->rowCount() - 1,

QListView.indexAt in PyQt5 returning wrong index?

孤街浪徒 提交于 2021-01-28 14:51:56
问题 I'm trying to pop up a context menu when a user right-clicks on an item in a QListView and a different context menu if the user right-clicks outside of any of the items (any of the whitespace). What I'm finding is that the index I'm receiving when performing the indexAt command is not accurate, and I can't figure out why. I initialize the QListView as its own class: class RBKDataTypesTab(QWidget): def __init__(self): super().__init__() self.models = [] grid = QGridLayout() self.list =

QListView.indexAt in PyQt5 returning wrong index?

妖精的绣舞 提交于 2021-01-28 14:49:49
问题 I'm trying to pop up a context menu when a user right-clicks on an item in a QListView and a different context menu if the user right-clicks outside of any of the items (any of the whitespace). What I'm finding is that the index I'm receiving when performing the indexAt command is not accurate, and I can't figure out why. I initialize the QListView as its own class: class RBKDataTypesTab(QWidget): def __init__(self): super().__init__() self.models = [] grid = QGridLayout() self.list =

QListView.indexAt in PyQt5 returning wrong index?

懵懂的女人 提交于 2021-01-28 14:49:42
问题 I'm trying to pop up a context menu when a user right-clicks on an item in a QListView and a different context menu if the user right-clicks outside of any of the items (any of the whitespace). What I'm finding is that the index I'm receiving when performing the indexAt command is not accurate, and I can't figure out why. I initialize the QListView as its own class: class RBKDataTypesTab(QWidget): def __init__(self): super().__init__() self.models = [] grid = QGridLayout() self.list =

python - checkbox selection in QListView

╄→尐↘猪︶ㄣ 提交于 2020-07-09 05:11:32
问题 So, I developed a simple dialog with a checkbox, which allows the user to select one or several items from a list. Besides the standard OK and Cancel buttons, it adds Select All and Unselect All buttons, allowing the user to check/uncheck all items at once (this comes handy for large lists). import os, sys from PyQt4 import Qt, QtCore, QtGui class ChecklistDialog(QtGui.QDialog): def __init__(self, name, stringlist=None, checked=False, icon=None, parent=None): super(ChecklistDialog, self)._