qabstractitemmodel

QTableView sorting signal?

陌路散爱 提交于 2019-12-08 20:03:45
问题 I use QTableView + QStandardItemModel to show some data (data stored in some other data structure), and this table view is sortable . Since it is sortable, when sorting this model, I also need to sort the order of stored data. I try to implement a slot for the sorting signal, but I don't know what signal is emitted when clicking the header to start the sorting action. I tried the clicked signal, but it's only emitted for data row, not for the headerData. what should I do if I want to do

QAbstractItemModel + ModelTest::rowsInserted ASSERTion problem

白昼怎懂夜的黑 提交于 2019-12-08 02:06:01
问题 I'm trying to debug my model (QAbstractItemModel) with ModelTest. And I can't understand one assertion. There are two slots in ModelTest that intercept signals generated by my model. ModelTest::rowsAboutToBeInserted ModelTest::rowsInserted Slot/function 1 looks like this void ModelTest::rowsAboutToBeInserted ( const QModelIndex &parent, int start, int end ) { Changing c; // ... c.last = model->data ( model->index ( start - 1, 0, parent ) ); c.next = model->data ( model->index ( start, 0,

How to update QAbstractTableModel and QTableView after sorting the data source?

拈花ヽ惹草 提交于 2019-12-07 07:05:32
问题 I have a custom data structure that I want to display in a PyQt application using a QTableView. I'm using a subclass of QAbstractTableModel to communicate with the data. The data structure itself is in a separate module and knows nothing about PyQt. Displaying and editing the data with the QTableView works, but now I'd like to sort the data and then update the model and view. After reading the Qt documentation for QAbstractTableModel and its ancestor QAbstractItemModel, my first approach was

QAbstractItemModel and QTreeView [closed]

拟墨画扇 提交于 2019-12-07 01:35:34
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . I need working examples (c++) of show own data model in QtreeView. 回答1: There's a pretty good QTreeView/QAbstractItemModel example here. It's fairly straightforward once you get used to QT's ultra-generic model..

QAbstractItemModel + ModelTest::rowsInserted ASSERTion problem

时光毁灭记忆、已成空白 提交于 2019-12-06 05:47:21
I'm trying to debug my model (QAbstractItemModel) with ModelTest. And I can't understand one assertion. There are two slots in ModelTest that intercept signals generated by my model. ModelTest::rowsAboutToBeInserted ModelTest::rowsInserted Slot/function 1 looks like this void ModelTest::rowsAboutToBeInserted ( const QModelIndex &parent, int start, int end ) { Changing c; // ... c.last = model->data ( model->index ( start - 1, 0, parent ) ); c.next = model->data ( model->index ( start, 0, parent ) ); insert.push ( c ); } And slot 2 looks like this void ModelTest::rowsInserted ( const

base class 'QAbstractListModel' has private copy constructor

。_饼干妹妹 提交于 2019-12-06 03:32:17
问题 I have a QT QML project. (still very small) I started by binding a listview on my UScenario model, by subclassing QAbstractListModel and it worked fined. Now, each UScenario has a list of UTask , which also have a list of UCondition (so, Utask also subclasses QAbstractListModel ). But then, QT Creator gives me an error: Core/Tasks/utask.h:6: erreur : base class 'QAbstractListModel' has private copy constructor class UTask: public QAbstractListModel ^ So I'm not sure where is my problem. I

“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

Setting custom data for the QStringListModel item

让人想犯罪 __ 提交于 2019-12-05 18:33:08
I have QStringListModel QStringListModel* blocksModel = new QStringListModel(); And a class inherited from the QObject class Block : public QObject { Q_OBJECT public: Block(); Block(const Block& other); ~Block; //and other stuff here }; Q_DECLARE_METATYPE(Block*) When I set a data for the Qt::EditRole, everything works fine but when I'm trying to set data for the Qt::UserRole, it never returns true, and when I'm getting data I see invalid QVariant int count = blocksModel->rowCount(); blocksModel->insertRows(count, 1); QModelIndex index = blocksModel->index(count, 0); // it works QString name =

How to update QAbstractTableModel and QTableView after sorting the data source?

孤者浪人 提交于 2019-12-05 16:50:00
I have a custom data structure that I want to display in a PyQt application using a QTableView. I'm using a subclass of QAbstractTableModel to communicate with the data. The data structure itself is in a separate module and knows nothing about PyQt. Displaying and editing the data with the QTableView works, but now I'd like to sort the data and then update the model and view. After reading the Qt documentation for QAbstractTableModel and its ancestor QAbstractItemModel, my first approach was to try this: class MyModel(QtCore.QAbstractTableModel): __init__(self, data_structure): super().__init_

QAbstractItemModel and QTreeView [closed]

浪尽此生 提交于 2019-12-05 06:28:00
I need working examples (c++) of show own data model in QtreeView. Nathan Pitman There's a pretty good QTreeView/QAbstractItemModel example here . It's fairly straightforward once you get used to QT's ultra-generic model... just don't expect it to be as simple or obvious as Java's TreeModel. 来源: https://stackoverflow.com/questions/4354515/qabstractitemmodel-and-qtreeview