![]() ![]() Visit In QT, chaining models does not work as expected for more informations. I just reimplemented ProxySourceDataModel::index() to return local indexes, and it works like a charm. The problem was that the view do not use QAbstractItemModel::data() from its model, but rather calls QModelIndex::data() on its items, which in turn calls the QAbstractItemModel::data() of the item's underlying model.Īnd since my proxy returned model indexes from the underlying model, that is why the SourceDataModel::data() was always called instead of ProxySourceDataModel()! tModel( new ProxySourceDataModel(sourceDataModel) ) Īny help or advice greatly appreciated, thanks for reading! Return filter( model_.data(index,role) ) Virtual QVariant data( const QModelIndex& index,int role=Qt::DisplayRole ) After studying how they worked and asking a lot of questions things became operational. I started building models as a child and eventually picked up some antique industrial equipment. This is where I was hoping to do the filtering It is a place to create things you envision and make them real. For all QAbstractItemModel's virtual function, I do something like this QObject::connect( &model_, SIGNAL( the_signal()), For all QAbstractItemModel's signals emitted by the underlying model, ProxySourceDataModel(SourceDataModel& model) Here is some code to illustrate what I'm doing: class SourceDataModel : public QAbstractItemModelĬlass ProxySourceDataModel : public SourceDataModel But still, only SourceDataModel::data() is called. The data is not filtered at all! I overloaded data() in ProxySourceDataModel, and forward all the other calls to the underlying SourceDataModel. 100 mm round bases for wargaming, 4 pack. But using the ProxySourceDataModel i can't select anything. 6 pack of Chariot or Monster bases 50mm X 100mm- solid style. If I use the SourceDataModel directly, no problem. I am not able to select the data in the views. No problem, i did it.īut still 2 problems remain, and I can't figure out how to handle them: After some investigation, it seems that it was because i had to forward the signals and slots from the underlying SourceDataModel. From this ProxySourceDataModel, I noticed that no data was displayed when I used it in a QTableView. So I started to create a ProxySourceDataModel class, which inherits from my SourceDataModel and stores one instance, and basically delegates everything to the instance. Now, I would like to be able to filter this data, that is So, I have a SourceDataModel class, inheriting from QAbstractItemModel that seems to work properly (currently, I only display it in QTableView/QTreeView but later on, I'll create some custom views). I'm writing a Qt application to allow the visualization of very heavy data sets.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |