qlistview

How to make item view render rich (html) text in PyQt?

烂漫一生 提交于 2019-12-10 17:37:58
问题 I'm trying to translate code from this thread in python: import sys from PyQt4.QtCore import * from PyQt4.QtGui import * __data__ = [ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.", "Excepteur sint

Add a delete Button to each Item in QListView

℡╲_俬逩灬. 提交于 2019-12-10 17:18:48
问题 Is it somehow possible to add to each Item in a QListview a Button which is deleting the Object onClick? As shown in the following Picture: EDIT: As I'm new in QT it would be nice to have some example, to understand it better. And as it seems there are three different Ways? What will be the best? Do use a QAbstractItemView? 回答1: Yes. You'll need to use: QAbstractItemView::setIndexWidget ( const QModelIndex & index, QWidget * widget ) QListView inherits QAbstractItemView and when you're trying

Is there a way to add sections to QListView?

不想你离开。 提交于 2019-12-10 13:37:43
问题 I'm using Qt5.2 anc C++ to implement an application and need to display a list with sections similar to the example image below: (source: ngo-hung.com) Please note I'm not implementing a mobile app and I don't need the alphabet index on the right. Any suggestions how I can achieve this other than implementing a QTreeView? Thanks. 来源: https://stackoverflow.com/questions/25560547/is-there-a-way-to-add-sections-to-qlistview

How can I apply a graphic effect to the image in QListView?

不打扰是莪最后的温柔 提交于 2019-12-10 12:08:26
问题 I would like to apply some graphic effect to the pixmap of the list item in QListView. What should i do to achieve that? As far as i understand, i need to make my own delegate for that. But how do i use QGraphicsEffect in it? Update. If QListWidget is used, i can do something to the following effect. Create widgets for every list item and apply desired QGraphicsEffect for them. This widget would go like this (for example): class PortraitViewWidget : public QFrame { Q_OBJECT public: explicit

QListView & QStandardItemModel check text before editing row

让人想犯罪 __ 提交于 2019-12-08 04:24:22
问题 I want to check the text of a row in QListView before the user is editing it. If it doesn't fit a pattern, I don't want to accept it. Currently I have a QListView and QStandardItemModel . I can easily add and remove items via the QStandardItemModel . I also set the model of the list view. Are there some delegates or event function(s) on the list or the model for editing? 回答1: you can overload data() and setData() functions from QStandardItemModel , then when user tries to edit item your

Filtering QFilesystemModel

核能气质少年 提交于 2019-12-08 01:42:50
问题 I'm using a QFileSystemModel with a QListview to display all files from a directory. I'd like to filter that model to display some categories of files like : textual files : *.txt *.csv *.tab music : *.mp3 *.flac *.ogg movies : *.avi *.mkv My current code is : MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { Filemodel = new QFileSystemModel(this) ; Filemodel->setFilter( QDir::NoDotAndDotDot | QDir::Files ) ; proxy_model = new QSortFilterProxyModel();

Filtering QFilesystemModel

删除回忆录丶 提交于 2019-12-06 13:32:01
I'm using a QFileSystemModel with a QListview to display all files from a directory. I'd like to filter that model to display some categories of files like : textual files : *.txt *.csv *.tab music : *.mp3 *.flac *.ogg movies : *.avi *.mkv My current code is : MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { Filemodel = new QFileSystemModel(this) ; Filemodel->setFilter( QDir::NoDotAndDotDot | QDir::Files ) ; proxy_model = new QSortFilterProxyModel(); proxy_model ->setDynamicSortFilter(true); proxy_model ->setSourceModel( Filemodel ); proxy_model -

QListView item with checkbox selection behavior

回眸只為那壹抹淺笑 提交于 2019-12-06 12:35:57
问题 I'm adding checkbox items to a list view. Then when I change the check box indicator, the item row is not selected. And when I'm selection an item in the list, the check box indicator won't change. The checkbox indicator should be selected/deselected on item selection row, and checkbox indicator selection should set the item row selected. List view init: QListView *poListView = new QListView(this); // Create list view item model QStandardItemModel* poModel = new QStandardItemModel(poListView)

QT4 QstringListModel in QListView

折月煮酒 提交于 2019-12-06 02:49:12
问题 This is my first QT question - I'm generally a C# programmer so forgive me for asking a stupid question for which I'm sure there's a very simple answer, which I just can't seem to find: I want to add items to a list, for the moment let's say they're strings. I have a QListView: UI->listView , a QStringList, and a QStringListModel: stringList = new QStringList(); stringList->append("ABC"); stringList->append("123"); listModel = new QStringListModel(*stringList, NULL); ui->listView->setModel

Qt Drag and Drop QListView removing the item on which it is released

爷,独闯天下 提交于 2019-12-05 00:41:53
问题 I working on a small QlistView which is Sortable. iListView = new QListView(this); //Creating a standard item model iStandardModel = new QStandardItemModel(this); //First item QStandardItem* item1 = new QStandardItem(QIcon(":/cover-story-album-art.jpg"),"First Item"); //Second item QStandardItem* item2 = new QStandardItem(QIcon(":/cover-story-album-art.jpg"),"Second item"); //third item QStandardItem* item3 = new QStandardItem(QIcon(":/cover-story-album-art.jpg"),"Third![enter image