Questions tagged [qstandarditemmodel]

The QStandardItemModel class provides a generic model for storing custom data.

The QStandardItemModel class provides a generic model for storing custom data.

QStandardItemModel can be used as a repository for standard Qt data types. It is one of the Model/View Classes and is part of Qt's model/view framework.

QStandardItemModel provides a classic item-based approach to working with the model. The items in a QStandardItemModel are provided by QStandardItem.

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

233 questions
3
votes
1 answer

QSortFilterProxyModel with QStandardItemModel after appendRow are not working

Here what I have got: a QTreeView widget (*); Source model MainModel inherits from QStandardItemModel. No virtual data() const method reimplemented; Proxy MainFilterProxyModel inherits from QSortFilterProxyModel; The tree: [PERIOD 1] [CHILD 1] …
mosg
  • 12,041
  • 12
  • 65
  • 87
2
votes
1 answer

Custom sorting method of QTableView?

How can I setup custom sorting method for a QTableView , or for the model ? (Which function should I re-implement) The default sorting algorithm are for strings , I want a number sorting method for some specific column. Thanks.
daisy
  • 22,498
  • 29
  • 129
  • 265
2
votes
2 answers

Change text of QStandardItem when editing starts

Using Qt4's model/view framework, I have a list of items displayed as "Foo (38 bars)". I want to make the text editable, but when the user starts editing, I want the control to just show "Foo" (the name), and then to reinstate the extra info "(38…
Thomas K
  • 39,200
  • 7
  • 84
  • 86
2
votes
1 answer

Set selection of item in QStandarItemModel with Qlistview

I have a Qlistview with some items. I want to set selection at first item at startup of window. selectionModel().selectedRows() returns the selectet item. But QAbstractItemModel().setCurrentIndex(0) does't select the item. How could that be done…
Pavel.D
  • 561
  • 1
  • 15
  • 41
2
votes
1 answer

How to filter out individual items instead of just on a row and column basis?

I am trying to filter out items in a table based on string matching. I have a QTableView displaying a Proxy Model to allow for filtering, however if an item in (0,0) and in (1,1) matches my string but item (1,0) doesn't, it will still be displayed.…
2
votes
1 answer

QStandardItemModel::findItems does not search in QModelIndex(row, col, QModel(row,col))

I'm trying to create hierarchical tree from sql database. Tree nodes can have the same name, but unique ID. Therefore I search for a node parent by its ID, recognize its index and insert a new child row. Also I know how QModelIndexes are represented…
Loki
  • 21
  • 2
2
votes
2 answers

Populate QTreeView as parent and child nodes from database

I have data stored in the following columns in the database |AcName|ActCod|GroupCode| |parent1| |1| |0| |child1| |101| |1| |parent2| |2| |0| |child2| |201| |2| I am using a QTreeView, QStandardItemModel, and QStandardItem to create this…
awaisharoon
  • 463
  • 1
  • 3
  • 16
2
votes
3 answers

Append Class to QStandardItemModel

How can I append my items of class BundleItem to the QListView's QStandardItem model? When they are appended, I only want to use the BundleItem's Name property to be displayed in the listview. I would like a pointer to the actual item to live in the…
JokerMartini
  • 5,674
  • 9
  • 83
  • 193
2
votes
2 answers

Get selected index in QListView using QStandardItemModel

I am creating a QListView and QStandardItemModel using this code: self.listView = QtWidgets.QListView(self.groupBox2) self.listView.setGeometry(QtCore.QRect(200, 20, 400, 220)) self.entry = QtGui.QStandardItemModel() I am adding items in a loop…
j.Doe
  • 202
  • 4
  • 18
2
votes
1 answer

QTreeView and using QStandardModel to append items

I using QStandardItemModel to maintain QTreeView, and how can I modify or delete the red circle in the images below . Thanks. from PySide2 import QtCore,QtGui from PySide2.QtGui import QStandardItemModel import pandas as pd class…
Relax ZeroC
  • 651
  • 1
  • 12
  • 27
2
votes
1 answer

Modifying QStandardItemModel from non-UI QThread?

I have Qt4 app which binds QStandardItemModel to the QListView and have the model updated from background/non-UI thread. Sometimes, when the QStandardItem's setText(..) method is called very repeatedly from the non-UI thread, the application will…
Gant
  • 29,661
  • 6
  • 46
  • 65
2
votes
1 answer

QStandardItem checkbox changes reflected on object in Pyside

How can I sync the checkboxes in the UI with the properties they are representing? So when I change the checkbox state in the UI it properly sets the value of the property on the class object to match the checkbox state? For example if i click the…
JokerMartini
  • 5,674
  • 9
  • 83
  • 193
2
votes
0 answers

EventFilter capturing events from Different Objects on Mac and Windows

I am working on an application for Windows and Mac. I am noticing different behavior for Mac and Windows. When I set a QLIstView for a QComboBox and try to capture the Enter/Return press events from the PopUp of the comboBox, the eventFilter gets…
Sadaab
  • 83
  • 1
  • 1
  • 7
2
votes
2 answers

how to get the pyqt qtreeview item child using double click event?

I'm using PyQt4 and python 2.7.9. I have a QTreeView that contains data from Oracle database. the code is this: model = QStandardItemModel(0,1) self.treeMedia.setModel(model) for rowalb in self.SELECT_TREE_ALBUM(codus): nodeItem =…
2
votes
1 answer

Manipulating data in a QStandardItemModel/QTreeView?

In my project, I parse a data file and create a QStandardItemModel based off that file which is then displayed in a QTreeView. The model gets created fine and I know how to set certain parameters for each QStandardItem when it is created. For…
mrg95
  • 2,371
  • 11
  • 46
  • 89
1 2
3
15 16