qlistview

Is there a way to display icons in QListView without text?

北城余情 提交于 2019-12-04 21:44:15
问题 Using a QListView, and QStandardItemModel, is it possible to display icons in the list view without displaying the associated text? QStandardItem is defined as so: QStandardItem ( const QIcon & icon, const QString & text ) So it seems to require a text string of some sort - I only want the icon displayed. If I use the following code, I get the icons as requested, but I also get a blank text element underneath them. I don't want this. ImageListView->setViewMode( QListView::IconMode ); {

QListView item with checkbox selection behavior

馋奶兔 提交于 2019-12-04 20:16:58
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); QStandardItem *poListItem = new QStandardItem; // Checkable item poListItem->setCheckable( true ); //

QT4 QstringListModel in QListView

那年仲夏 提交于 2019-12-04 06:57:05
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(listModel); stringList->append("xyz"); This example compiles and disaplys "ABC" and "123" in my list, but

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

纵饮孤独 提交于 2019-12-03 15:54:37
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 description here][1] item"); //Appending the items into model iStandardModel->appendRow(item1); iStandardModel-

Is there a way to display icons in QListView without text?

不问归期 提交于 2019-12-03 13:43:02
Using a QListView, and QStandardItemModel, is it possible to display icons in the list view without displaying the associated text? QStandardItem is defined as so: QStandardItem ( const QIcon & icon, const QString & text ) So it seems to require a text string of some sort - I only want the icon displayed. If I use the following code, I get the icons as requested, but I also get a blank text element underneath them. I don't want this. ImageListView->setViewMode( QListView::IconMode ); { QStandardItemModel *iStandardModel = new QStandardItemModel(this); QStandardItem* item1 = new QStandardItem

How to clear the selection of QListView when multiple items are selected?

▼魔方 西西 提交于 2019-12-02 04:22:28
问题 I am working on a Qt App where I have a QListView. There are few items present in the list. My application requires items to be rearranged according to user's choice. Everything is working fine but I am facing a small issue. When I do multiple selection using a mouse i.e. select items by dragging the mouse, it leaves the selection mark on the QlistView even after I do some rearranging operation. I am sure its got something to do with clearing the selection. I tried to use repaint() or

How do I tell QListView to resize to fit?

流过昼夜 提交于 2019-12-02 03:53:36
I have a QListView and have assigned a model and a delegate. I am using it to display images in a horizontal bar as below On a user event, data is updated in the model. One such event causes the width of the images to be reduced like below(#4). I emit a dataChanged on the corresponding index and only the concerned widget is repainted. Because of this, there is a gap between #4 and #5 which does not get filled. I am thinking that there must be a way to refresh all visible rows - but am unable to find it. I tried the following, but they do not work: 1. viewport()->updateGeometries() 2. viewport(

How to clear the selection of QListView when multiple items are selected?

∥☆過路亽.° 提交于 2019-12-02 01:45:57
I am working on a Qt App where I have a QListView. There are few items present in the list. My application requires items to be rearranged according to user's choice. Everything is working fine but I am facing a small issue. When I do multiple selection using a mouse i.e. select items by dragging the mouse, it leaves the selection mark on the QlistView even after I do some rearranging operation. I am sure its got something to do with clearing the selection. I tried to use repaint() or clearFocus() but nothing seems to be working. E.g When we select a group of folders we drag our mouse, which

Remove QListView background

ぃ、小莉子 提交于 2019-12-02 00:56:52
问题 I want to remove the background of my QListView so that the background below can be seen through. How can I do that? I tried setAttribute(Qt::WA_NoSystemBackground) and setAttribute(Qt::WA_NoBackground) but that didn't change anything. Also I cannot override paintEvent() otherwise it doesn't draw the items. Any idea? 回答1: Don't forget that QScrollArea, which is base class for QListView contains "another" widget which is called Viewport. It can be accesed via viewport() method. To achieve

Remove QListView background

十年热恋 提交于 2019-12-01 23:28:55
I want to remove the background of my QListView so that the background below can be seen through. How can I do that? I tried setAttribute(Qt::WA_NoSystemBackground) and setAttribute(Qt::WA_NoBackground) but that didn't change anything. Also I cannot override paintEvent() otherwise it doesn't draw the items. Any idea? rob Don't forget that QScrollArea, which is base class for QListView contains "another" widget which is called Viewport. It can be accesed via viewport() method. To achieve transparency You can simply just call: viewport()->setAutoFillBackground( false ); and depending on other