Quantcast
Viewing all articles
Browse latest Browse all 4972

Model from C++ to QML

Thanks a lot, I finally managed to do what I needed. If someone else would read this topic, I found some useful information also here [stackoverflow.com] Now I’m facing one more problem (I hope the last one). :-) Following the guide I have this function in “myModel”: void LibraryModel::addItem(const LibraryItem &item) {     beginInsertRows(QModelIndex(), rowCount(), rowCount());     m_items << item;     endInsertRows(); } If I add some items to my list model, it is not shown immediately. Sometimes it appears after a few seconds, sometimes never. What am I missing? Do I have to emit a signal that the model has changed? I thought the functions beginInsertRows() and endInsertRows() is meant to do this. Another question is, if I should call addItem for each item (I’m reading database results and appending it one by one) or should I rather store all the list items in a list and then implement in my model addItems function, to add all the items at once? I hope it is understandable what I’m asking…

Viewing all articles
Browse latest Browse all 4972

Trending Articles