model-view

How to display sub-rows of QAbstractItemModel in QTableView

大兔子大兔子 提交于 2019-12-10 10:38:14
问题 I have my own class that inherits from QAbstractItemModel which has tree structure. I use a couple of views, that display filtered data of this model, using classes derived from QSortFilterProxyModel. My model structure looks like this: root | -- A | |-A1 | |-A2 | |-A3 | -- B | |-B1 | |-B2 | ... and so on... Where A, B .... are "main rows" (children of the root), and A1, A2, ... B1, B2... are "children rows" - node rows appended to "main rows". Now, what I need to do is a QTableView that

Using QTableView with a model

倖福魔咒の 提交于 2019-12-07 01:27:30
问题 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 this right? void MainWindow::on_actionBy_registration_number_triggered() { myDialog = new MyDialog(this); myDialog->exec(); QString toSearchString = myDialog->getRegistrationNumber(); QVector<Vehicle> founded; QVectorIterator<Vehicle> iterator(cars);

QTreeView or QTreeWidget

徘徊边缘 提交于 2019-12-06 23:49:02
问题 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 many times it was done/missed/failed and lastly a score for that day. I want to display them like so: I made this example in QtCreator using a QTreeWidget, but I'm worried that it would be hard to modify the elements since they are stored somewhere

canFetchMore() and fetchMore() are not working as expected

最后都变了- 提交于 2019-12-06 07:41:57
I have problems implementing Qt tree model with lazy loading using canFetchMore() and fetchMore() . I have this code: from PySide.QtCore import Qt, QAbstractItemModel, QModelIndex from PySide.QtWidgets import QTreeView, QApplication BATCH_SIZE = 100 class ObjectItem(object): def __init__(self, parent, name, data, row): self.parent = parent self.name = name self.data = data self.row = row self.hasChildren = False self.canFetchMore = False # ints have no children if isinstance(data, int): return self.childCount = 0 self.childItems = [] if len(data) > 0: self.canFetchMore = True self.hasChildren

How to display sub-rows of QAbstractItemModel in QTableView

不羁的心 提交于 2019-12-06 05:06:03
I have my own class that inherits from QAbstractItemModel which has tree structure. I use a couple of views, that display filtered data of this model, using classes derived from QSortFilterProxyModel. My model structure looks like this: root | -- A | |-A1 | |-A2 | |-A3 | -- B | |-B1 | |-B2 | ... and so on... Where A, B .... are "main rows" (children of the root), and A1, A2, ... B1, B2... are "children rows" - node rows appended to "main rows". Now, what I need to do is a QTableView that displays "children rows" only: A1 A2 A3 B1 B2 But filtering methods I found in QSortFilterProxyModel

QTreeView or QTreeWidget

旧街凉风 提交于 2019-12-05 03:45:19
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 many times it was done/missed/failed and lastly a score for that day. I want to display them like so: I made this example in QtCreator using a QTreeWidget, but I'm worried that it would be hard to modify the elements since they are stored somewhere else. Are my worries rational and should I go to the model/view structure, or can I easily get going

Shared ViewModel lifecycle for Android JetPack

淺唱寂寞╮ 提交于 2019-12-04 11:52:13
问题 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 tabs fragments. Each such page has own ViewModel which should be shared with all contained fragments. The key trick here is to use Activity instead of Fragment to hold my ViewModel. The problem is that my Activity can have multiple pages with own

Pyqt4 Model View - Adding Slider , CheckBox Line Edit in Table model

ε祈祈猫儿з 提交于 2019-12-04 06:50:52
问题 I am working on a ui as shown in the image below. In the First columns i have a Check Box, Second columns i have a Slider, Third just text the slider value applied to a function. the result will be shown in the third column. I am not not able to see the slider not the checkbox Output is shown in the image Code: from PyQt4 import QtGui, QtCore, uic import sys from PyQt4.QtCore import * from PyQt4.QtGui import * class PaletteTableModel(QtCore.QAbstractTableModel): def __init__(self, colors = [[

Qt: start editing of cell after one click

﹥>﹥吖頭↗ 提交于 2019-12-03 15:28:12
问题 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 clicking on the cell the QComboBox editor is activated but not expanded. I want it to expand after just one click as if I added QComboBox by setCellWidget function of QTableWidget . I need the same effect by using model-view-delegate. 回答1: Edit after

Shared ViewModel lifecycle for Android JetPack

﹥>﹥吖頭↗ 提交于 2019-12-03 06:51:36
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 tabs fragments. Each such page has own ViewModel which should be shared with all contained fragments. The key trick here is to use Activity instead of Fragment to hold my ViewModel. The problem is that my Activity can have multiple pages with own models and holding the view model for particular page all the time is waste of device resources. Is