user63898
user63898

Reputation: 30885

QStandardItemModel append new items on top of the rest

i like to make my QStandardItemModel that populates items in qtreeview to append rows on top the allready defined items in the view . something like the twitter view , new items first. all i see in the QStandardItemModel is the appendRow/s that appends then to button. this is what im using now.

SWidget *widget = new SWidget;
            QStandardItem *newItem = new QStandardItem;
            newItem->setSizeHint( widget->size() );
            appendRow( newItem );
            view->setIndexWidget( newItem->index(), widget );

Upvotes: 1

Views: 1410

Answers (1)

Bill
Bill

Reputation: 11822

void QStandardItemModel::insertRow ( int row, QStandardItem * item ) inserts a row at row containing item. So instead of calling appendRow(newItem); call insertRow(0, newItem);

Upvotes: 2

Related Questions