qsortfilterproxymodel

pyqt5: Properly update QTreeView after data change on the database

我与影子孤独终老i 提交于 2019-12-11 17:35:32
问题 I have a model-based QTreeView which is fed by a QSortFilterProxyModel. I am displaying rows from the database here. With a double-click I am executing a modal QDialog to edit the data (the user can do CRUD operations like create new rows into my SQLite data base, updates, delete etc.). On closing the edit-dialog the focus gets back to the underlying QTreeView. Now I would like to refresh the changed data from the database. One way to do this would be to build up my complete model and refetch

How to reenable manual column layout in a QTreeView with QSortFilterProxyModel

不想你离开。 提交于 2019-12-11 06:46:12
问题 I have a QTreeView which displays data from a SQLite database. The QTreeView has filters and sorting enabled. For filtering I display a QLineEdit into the column header. Problem: the column layout seems to be fixed by the modifications in order to enable the QLineEdit filtering. Question: Is there a way to reenable the arrangement of the column layout - via dragging the columns, as it is in the standard QTreeView layout. I want the user to be able to rearrange his columns the desired way.

QTableView: sort by header index -1

扶醉桌前 提交于 2019-12-11 04:19:12
问题 I am using PyQt4 and have a QTableView with a 2 columns data. There is an extra column for an index (it comes from the headerData function of the source model). For sorting when clicking on the header buttons I wrap my model with a proxy class. That's working fine, but I also want to sort by the first column by clicking on the left-top corner button (column number: "-1" I would say) : As requested, here is a minimal example: from PyQt4 import QtCore, QtGui import random, sys class MyModel

Chained QSortFilterProxyModels

六月ゝ 毕业季﹏ 提交于 2019-12-09 12:28:34
问题 Let's say I have a list variable datalist storing 10,000 string entities. The QTableView needs to display only some of these entities. That's is why QTableView was assigned QSortFilterProxyModel that does all the filtering. After all Proxy work is completed the QTableView "receives" 25 entities to display (so remaining 9,975 entities were "filtered out". Now, I create a QLineEdit to be used as a search field where the user can type a keyword to narrow down the list of the displayed 25

PyQt QWidget in QAbstractListModel gets deleted with QSortFilterProxyModel

99封情书 提交于 2019-12-08 02:03:51
问题 I need to populate a listview with widgets, then have a custom proxyfilter work with it. Without the filter it works great, when active it seems to delete the widgets attach to the model. It shows up fine showing all items, filtering works but when erasing the filter, when hidden widgets should be shown again following error gets thrown: custom_widget.setGeometry(option.rect) RuntimeError: underlying C/C++ object has been deleted Tried not using QVariant and going the internalPointer route

Sort a QAbstractListModel derived model by role in QML ListView

Deadly 提交于 2019-12-07 04:58:55
问题 I've created a QAbstractListModel derived model based on an underlying QHash. Since I need to use the model in QML, I cannot make use of the sorting functionality Qt widgets and views have integrated. I tried using a QSortFilterProxyModel but it doesn't seem to work with my model. Getting the model to properly work in QML wasn't tedious enough, and now I am stuck on sorting. Any suggestions are appreciated. Here is the model source: typedef QHash<QString, uint> Data; class NewModel : public

“group by” proxy model

不打扰是莪最后的温柔 提交于 2019-12-05 22:05:08
I have tree model with theoretically infinite depth and some property "Group". In addition to standard view, I need to show this model (and keep it in sync) in such way that each group becomes a virtual parent for all items with the same property value. What is the best way to achieve this with Qt's model/view architecture? I had solved similar problem not a long time ago via inserting additional virtual "groups" on adding/removing items to/from the model, but this method proved not to be very flexible so I'm looking for better solution. Ideally, I see this implemented via QSortProxyFilter

Sort a QAbstractListModel derived model by role in QML ListView

和自甴很熟 提交于 2019-12-05 07:00:05
I've created a QAbstractListModel derived model based on an underlying QHash. Since I need to use the model in QML, I cannot make use of the sorting functionality Qt widgets and views have integrated. I tried using a QSortFilterProxyModel but it doesn't seem to work with my model. Getting the model to properly work in QML wasn't tedious enough, and now I am stuck on sorting. Any suggestions are appreciated. Here is the model source: typedef QHash<QString, uint> Data; class NewModel : public QAbstractListModel { Q_OBJECT Q_PROPERTY(int count READ count NOTIFY countChanged) public: NewModel

Change QSortFilterProxyModel behaviour for multiple column filtering

风流意气都作罢 提交于 2019-12-05 01:22:55
问题 We have a QSortFilterProxyModel installed on a QTableView and two (or more) QLineEdit for filtering the view (based on the text of these QLineEdit s) In our view we have a slot that tells us the string of lineedits and the current column that we want. Something like this : void onTextChange(int index, QString ntext) { filter.setFilterKeyColumn(index); filter.setFilterRegExp(QRegExp(ntext, Qt::CaseInsensitive)); } On the first column we have names in the second we have year of birthday. Now we

Change QSortFilterProxyModel behaviour for multiple column filtering

若如初见. 提交于 2019-12-03 15:18:05
We have a QSortFilterProxyModel installed on a QTableView and two (or more) QLineEdit for filtering the view (based on the text of these QLineEdit s) In our view we have a slot that tells us the string of lineedits and the current column that we want. Something like this : void onTextChange(int index, QString ntext) { filter.setFilterKeyColumn(index); filter.setFilterRegExp(QRegExp(ntext, Qt::CaseInsensitive)); } On the first column we have names in the second we have year of birthday. Now we enter a year for column 2 (for example 1985). Until now filtering is ok but when we switch to the