qabstractitemmodel

QObject::connect issues with QAbstractItemModel

Hey, I have a QListView from which I obtain a QAbstractItemModel with list->model(); After this, I want to connect the dataChanged signal to a custom QObject of mine: if( QObject::connect(model, SIGNAL(dataChanged (const QModelIndex , const QModelIndex ) ), customObject_,SLOT(onText(const QModelIndex , const Q...

Help getting inserted data after Qt's rowInserted signal

Hey, I have a onText method that connects to a QAbstractItemModel's rowsInserted SIGNAL so I can be notified when new rows have been inserted: QObject::connect(model, SIGNAL(rowsInserted ( const QModelIndex & , int , int ) ), client_,SLOT(onText( const QModelIndex & , int , int )) ) The signal works fine, since I am notif...

Can I declare a root item for a QAbstractItemModel?

I know there is the possibility of setting the parent model index for the item view, but I'd like to do this for the model. The reason is quite simple, I want to get rid of those constructs: # PyQt 4.5.4, but this should be similar to Qt. def insertRows(self, row, count, parent=QModelIndex()): if parent.isValid(): parentNod...

Supporting multi-add/delete (and undo/redo) with a QAbstractItemModel (C++)

Greetings, I've been writing some nasty code to support the undo/redo of deletion of an arbitrary set of objects from my model. I feel like I'm going about this correctly, as all the other mutators (adding/copy-pasting) are subsets of this functionality. The code is nastier than it needs to me, mostly because the only way to mutate the...

Most elegant/safe/easy solution to store and edit (GUI) a directory-like tree structure?

Hello, I've got a slightly tricky problem to solve; imagine this: One of my applications needs to make heavy use of scripting, so my idea was to provide the user a way to write script snippets and organize them in a directory-like tree structure. This is much like a source code directories with subdirectories and source files. Data Cl...

How to create artificial nodes in QAbstractItemModel for QTreeView

Hi, my question is about Qt and its QAbstractItemModel. I have a map of strings and doubles (std::map<stringclass, double>) which I would like to present in a Qt widget. While I could use QTableView for that, I would like to exploit the fact that the keys of the map are of form "abc.def.ghi" where there can be multiple strings that c...

How do I get my python object back from a QVariant in PyQt4?

I am creating a subclass of QAbstractItemModel to be displayed in an QTreeView. My index() and parent() function creates the QModelIndex using the QAbstractItemModel inherited function createIndex and providing it the row, column, and data needed. Here, for testing purposes, data is a Python string. class TestModel(QAbstractItemModel):...

QTableView sorting signal?

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 head...

HowTo find Subitem in QAbstractItemModel and QTreeView class?

Hello. Question: how to find sub item, in a QTreeView loaded QAbstractItemModel model with model->match() method? Problem: model->match() can't find sub items, wtf?! Here is the example: As you can see from the picture, I'm trying to expand Layouts sub item with this code: void Dialog::restoreState(void) { // get list QSet...

HowTo combine QAbstractTableModel and QItemDelegate to one working source?

Hi there! I have a QTableView defines in UI file. Here is the figure: I'd like to make month change (where the red array points) with QComboBox widget, dealing with delegates, but for me, for my custom delegate and model it's a too complex problem, and I can't figure out what is wrong?! Problem: on my opinion, QAbstractTableModel ca...