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

How to Populate a QStandardItemModel

I'm a beginner at Qt and I'm struggling to populate a QStandardItemModel from an XML file. I've tried the following and the entire project runs successfully but the QtableView does not display the data. Here is my main.cpp: void readXml(const…
Barry Michael Doyle
  • 9,333
  • 30
  • 83
  • 143
0
votes
2 answers

Base operand of '->' has non-pointer type 'QStandardItemModel'

I'm not 100% up to scratch regarding my understanding of pointers. I have some code that is giving me the following error: base operand of '->' has non-pointer type 'QStandardItemModel' Here is the relevant code: stocklist.h class…
Barry Michael Doyle
  • 9,333
  • 30
  • 83
  • 143
0
votes
0 answers

Remove a row from a QStandardItemModel where selected row is a QTableView

I have a Qt project where I have a QStandardItemModel called stockModel. This model is linked to a QTableView called tvStock. I have a button called btnDelete which has a clicked event set up as follows: void StockItems::on_btnDelete_clicked() { …
Barry Michael Doyle
  • 9,333
  • 30
  • 83
  • 143
0
votes
1 answer

Add data to QScrollArea dynamically

I have a QStandardItemModel and it contains my data which has around 5000 rows. I want to insert the data into QScrollArea in batches. If I insert it altogether the performance becomes really slow. Hence I want to add the data when it is required by…
Sandy
  • 11
  • 4
0
votes
1 answer

Updating QTableView after reading whole file to QStandardItemModel

I have some newbie question. I'm not sure if I understand Model-View-Controller design pattern correctly. Maybe I will start from describing my problem. I'm reading some data from file. This can take let's say 10 seconds and after that I present…
Cherubim
  • 55
  • 2
  • 8
0
votes
1 answer

How can I organize QStandardItemModel`s in one QTreeView

I have two QTreeView's. First (QTreeView1) displayed folders, second (QTreeView2) - displayed subfolders, that are loaded on folder click in first QTreeView1. On click by folder in QTreeView1, I create QStandardItemModel with subfolders and set…
Meteo ir3
  • 449
  • 8
  • 21
0
votes
1 answer

QSortFilterProxyModel how to handle QStandardItems correctly

I have QTreeView with some items and search QLineEdit with connected slot on textEdited signal. With this code: QSortFilterProxyModel *proxyModel = new…
0
votes
2 answers

QStandardItemModel* from non-GUI thread didn`t emit itemChanged signal

I have started database loading in non-GUI thread with QtCuncurrent::run. In this nonGui thread I have to create QStandardItemModel* and after that I received model in GUI thread with model = modelWatcher.result(); on QFutureWatcher finished()…
0
votes
1 answer

Auto update selection when a QStandardItem is disabled

I use Qt 5.6 and a QStandardItemModel filled with QStandardItem to display a data table. Some items are enabled, some are not. Only enabled items can be selected (this is the normal behavior). But when the data are updated, some items enabled state…
Aurelien
  • 1,032
  • 2
  • 10
  • 24
0
votes
1 answer

Get all lines between two specific lines in csv file using Qt

I am reading a csv file in qt using the following code: QStandardItemModel* readFile() { QFile config_file(FILE_PATH); if (config_file.open(QIODevice::ReadOnly)) { int lineindex = 0; QTextStream in(&config_file); …
smyslov
  • 1,279
  • 1
  • 8
  • 29
0
votes
1 answer

How to only show rows with columns that contain QStrings from a QStringList?

I've created a SortFilterProxyModel together with a QStandardItemModel and a QTreeView. I need to only show rows, where the second column is equal to one of the values in my QStringList. Can anyone tell me how to do this? I thought of…
Engo
  • 899
  • 3
  • 19
  • 49
0
votes
1 answer

Detect changes within QStandardItemModel

In order to save a QStandardItemModel to file, I would like to detect if changes where made to the model or not. Changes may be: Update of items Deletion of items New items (add / insert) Movement of items (e.g. wihtin a tree) The idea is to set a…
Tob
  • 286
  • 1
  • 17
0
votes
0 answers

Hide QStandardItemModel row in data member function

How can I hide / exclude entire rows from a QStandardItemModel without removing them physically from the model? Rational: I want to not display entities which are shown in another view. I already have a working highlight logic for that in the data…
Horst Walter
  • 13,663
  • 32
  • 126
  • 228
0
votes
1 answer

Drag & Drop of hidden QStandardItemModel columns in QTreeView

Within a QTreeView, I would like to copy rows around by drag and drop. The corresponding Drag & drop settings look like: this->setDragDropMode( QAbstractItemView::DragDrop ); this->setDropIndicatorShown( true ); This works fine unsing for the…
Tob
  • 286
  • 1
  • 17
0
votes
2 answers

QTreeView items editable and selecting whole rows

I have a QTreeView wich is alread connected to a Model (QStandardItemModel), so the Tree is filled and I can display it. When I double click on the items, the item edit mode is opened, where I am able to modify the fields content. I do not want to…
Ralf Wickum
  • 2,850
  • 9
  • 55
  • 103