Questions tagged [model-view]

model-view describes the relationship between the model and the view when using model-view-controller

Model-view-controller is an architecture to separate the model (data) and the view (interface). The model contains the information for a program while the view is the interface with the user. The controller is used to update the model from user input and to update the view when the model changes.

259 questions
25
votes
5 answers

Qt: start editing of cell after one click

By default the cell in QTableView starts being edited after double click. How to change this behavior. I need it to start editing after one click. I have set combo-box delegate to the cell. When clicking the cell it only selects it. When double…
Ashot
  • 10,807
  • 14
  • 66
  • 117
16
votes
2 answers

How to reset model in Qt?

I am using Qt model/view framework. When I reset the data in the model, I have to reset the model to let views update also. How to do it? I found a signal modelReset(QPrivateSignal); in the QAbstractItemModel, Is this the way to solve it? How to…
user1899020
  • 13,167
  • 21
  • 79
  • 154
15
votes
1 answer

QTreeView or QTreeWidget

I want to implement in my program a tree with nested sub-levels, and I'm looking for which of those two kind(View/Widget) is best suited for my goal. I have a list of days with task that are either done/missed/failed, each task has a count of how…
f.rodrigues
  • 3,499
  • 6
  • 26
  • 62
13
votes
1 answer

How to refresh a QSqlTableModel while preserving the selection?

I am using a QSqlTableModel and QTableView to view an SQLite database table. I would like to have the table auto refresh every second or so (it's not going to be a very large table - a couple of hundred rows). And i can do this - like so: QTimer…
will
  • 10,260
  • 6
  • 46
  • 69
11
votes
2 answers

Shared ViewModel lifecycle for Android JetPack

The documentation https://developer.android.com/topic/libraries/architecture/viewmodel#sharing describes how we can share the same ViewModel across the different Fragments. I have some complicated pages in my single Activity app with a container and…
11
votes
1 answer

Using QTableView with a model

I have the QVector cars that I want to filter basing on the car's registration number. I want to create a new filtered vector. I don't think that this is ok because i'm iterating 2 vectors, copying from the first one to the second one. Am I doing…
laura
  • 2,085
  • 13
  • 36
  • 68
10
votes
1 answer

How to properly use Dagger2 with the new Android Architecture Components

I'm trying to use the new Architecture Components, but I'm also still new to dagger and I'm missing stuff. With the below code, I'm getting a NullPointerException, can't locate where. Also if there's something else I need to fix or improve, please…
Relm
  • 7,923
  • 18
  • 66
  • 113
9
votes
2 answers

QTableView scroll to new added row

To add new rows to model I am calling beginInsertRows and endInsertRows(). How to configure the view to scroll to new added rows and select it. I can do it by sending some signals but maybe Qt has standard way for it.
Ashot
  • 10,807
  • 14
  • 66
  • 117
7
votes
3 answers

Qt: How to implement simple internal drag&drop for reordering items in QListView using a custom model

I have a QList of custom structs and i'm using custom model class (subclass of QAbstractListModel) to display those structs in 1-dimensional QListView. I have overriden the methodsrowCount, flags and data to construct a display string from the…
Youda008
  • 1,788
  • 1
  • 17
  • 35
7
votes
3 answers

QListView with millions of items slow with keyboard

I'm using a QListView with a custom model derived from QAbstractItemModel. I have on the order of millions of items. I have called listView->setUniformItemSizes(true) to prevent a bunch of layout logic from being called when I'm adding items to the…
Matthew Kraus
  • 6,660
  • 5
  • 24
  • 31
6
votes
1 answer

How to flag rows to be hidden in QAbstractItemModel-derived model

I'm implementing a Qt based tree view, where the view is a QTreeView-based class and the model is a QAbstractItemModel-based class. The tree is supposed to have millions of nodes in it. I'm implementing a filtering mechanism, in which filtered out…
susiriss
  • 83
  • 1
  • 5
6
votes
2 answers

PySide (PyQt) QAbstractItemModel

I am trying to implement a simple model for a treeview and I can't figure out why it isn't working.. It seems that all my nodes are children of my root node although three of them should be children of it's first child. Also I can see that my…
Stamoulohta
  • 649
  • 1
  • 7
  • 21
5
votes
1 answer

RxCpp RAII observable subscription

I am using RxCpp in a model-view setting. A view update method is subscribed to an observable (via lambda capturing this). Undefined memory access would ensue if the subscription were to outlive the view instance. I do not want the subscription to…
Jonathan Zrake
  • 603
  • 6
  • 9
5
votes
1 answer

QItemDelegate with custom view widget

Qt 5.5 has a virtual method to define a custom widget for editing mode: QWidget *createEditor(QWidget *parent,const QStyleOptionViewItem & option ,const QModelIndex & index ) const But how to use a custom widget to override the "view" mode? I saw…
Zelid
  • 6,905
  • 11
  • 52
  • 76
5
votes
2 answers

ListView highlight item isn't shown

I'm trying to highlight the currently selected item in a ListView. Below is the code I'm using; for some reason, while a similar code works perfectly in another ListView of this application, here the SelectedRectangle item is never displayed,…
Lisa Vitolo
  • 51
  • 1
  • 3
1
2 3
17 18