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
2
votes
1 answer

QT Hyperlink in QListView

Using Qt, I've created a gui that includes a QListView widget. This widget is being fed data from a QStandardItemModel object that is made with two columns: Description; and Hyperlink What I'm trying to do is to actually have the description…
Riaz Shageer
  • 141
  • 1
  • 15
2
votes
1 answer

Sorting a column alphabetically in QStandardItemModel: QSortFilterProxyModel

I am trying to sort Items in a specific column of QStandardItemModel alphabetically. For this I am using a class that derives from QSortFilterProxyModel and I am reimplementing the lessThan method as such bool MyProxy::lessThan(const QModelIndex…
MistyD
  • 16,373
  • 40
  • 138
  • 240
2
votes
1 answer

pyqt4: Making Qtableview reflect the changes after calling QStandardItem.setData

I'm trying to build a gui using pyqt4 and am having trouble updating fields on a Qtableview Here's my code: table=QTableView(myqMainWindow) model=QStandardItemModel(0,1,table) item1=…
Erric
  • 750
  • 9
  • 29
2
votes
3 answers

Read and write to a file from a QTableView

How can I read and write to a text file date enter to a QTableView? This is what I have but I would like to save the data when it is added to the table and of course be able to read it back when the application is reopened. Is there any tutorial I…
fs_tigre
  • 10,650
  • 13
  • 73
  • 146
2
votes
2 answers

How to set stylesheet for a single item in the Qlistview?

I have a QListView containing QStandardItems . How to set stylesheet for a single item in the Qlistview based on the QModelIndex acquired?
Gojira
  • 171
  • 4
  • 14
2
votes
1 answer

Extract texts of QHeaderView

I use QStandardModel::setHorizontalHeaderLabels(QStringList() << "XXX") to set the header text, how could I extract it from the model? I've checked the document about both QHeaderView and QStandardItemModel, but to no avail.
daisy
  • 22,498
  • 29
  • 129
  • 265
2
votes
2 answers

How to Sort ListView Items in Ascending Order?

I Tried to Sort my ListView Items in Ascending Order, so i tried with Model->sort(int Column, Qt::AscendingOrder) It Works Fine, but I don't like the Qt::AscendingOrder policy. Indeed the function first sorts words beginning with an uppercase…
New Moon
  • 787
  • 6
  • 21
  • 35
2
votes
1 answer

QStandardItemModel::removeRows() does not work in my use case

Basically I want to delete all rows in my model. I'd prefer to use removeRows(..) instead of clear(), because I want to keep my headers. I guess I have missed something (docu here), my code is pretty simple: int c =…
Horst Walter
  • 13,663
  • 32
  • 126
  • 228
1
vote
1 answer

QStandardItem converts unsigned int to int after editing

I create a QTableview with a QStandardItemModel, after editing the QStandardItem the type changed from unsigned int to int. This behavior just happen to unsigned int and just while the user is editing it, other datatypes stay. window.cpp #include…
nfo
  • 637
  • 2
  • 6
  • 19
1
vote
1 answer

Data from model not inserted in QTableView

I am trying to insert some data in a TableView from a model but I am doing something wrong because the data is not inserted. The table is updated with the columns and rows though. So I have a GraphicsView where I am drawing some custom…
schmimona
  • 849
  • 3
  • 20
  • 40
1
vote
1 answer

How to access nested QStandardItemModel's items from QML?

Background I have a tree-like QStandardItemModel, whose items I would like to access from QML. Here is how the model is defined on the C++ side: backend.h class Backend : public QObject { Q_OBJECT Q_PROPERTY(QStandardItemModel *model READ…
scopchanov
  • 7,966
  • 10
  • 40
  • 68
1
vote
1 answer

Appending a row with widgets and text to a QStandardItemModel

I want to append a QWidget to a QStandardItemModel in a QTableView self.table = QTableView() self.ui.scrollArea.setWidget(self.table) #Not important but I left it in in case it had something to do with this question self.model =…
Jakob
  • 15
  • 4
1
vote
1 answer

How to create an invalid QModelIndex?

I am implementing a function which searchs a QModelIndex based on a QString input. However if I cannot find this index, the function should retun an invalid index. My model is a QStandardItemModel. Is is okay to return invisibleRootItem()->index()…
Maitai
  • 42
  • 1
  • 10
1
vote
0 answers

Why a QPersistentModelIndex cannot be stored in one of the QStandardItemModel's items?

Background In my model I have to keep in one item's data, a reference to another item. The documentation of QPersistentModelIndex says: A QPersistentModelIndex is a model index that can be stored by an application, and later used to access…
scopchanov
  • 7,966
  • 10
  • 40
  • 68
1
vote
2 answers

Problems with displaying data in QListView

Good day! There are instances of classes QListView and QTreeView. Both of the instances loads data from model (QStandardItemModel). QTreeView displays positions (For example: Chief, Manager, Developer, etc). Clicking on the title of position a list…
Trainee
  • 61
  • 5