Hi.

Hi.

I use QTreeView to display dynamic data. I.e. rows can be inserted during program execution dynamically and values in some column can be changed dynamically too. But I need QTreeView to be sorted by the given by user column when new rows added.

I've connected to the rowsInserted signal:

connect(d->m_model,
        SIGNAL(  rowsInserted(  const  QModelIndex  &,  int,  int  )  ),
        this,  SLOT(  rowsAdded(  QModelIndex,  int,  int  )  )  );

And in the slot I do the next:

void
ChannelView::rowsAdded(  const  QModelIndex  &  parent,  int  start,  int  end  
)
{
        Q_UNUSED(  parent  )
        Q_UNUSED(  start  )
        Q_UNUSED(  end  )


        qDebug()  <<  "SORT"  <<  parent  <<  start  <<  end;

        d->m_sortModel->sort(  d->m_sortModel->sortColumn(),
                d->m_sortModel->sortOrder()  );
}

But I see that QTreeView doesn't sorted by the given column when the data in 
that column is static.

In the debug print I see the next:

SORT QModelIndex(-1,-1,0x0,QObject(0x0)) 0 -1
SORT QModelIndex(-1,-1,0x0,QObject(0x0)) 0 0
SORT QModelIndex(-1,-1,0x0,QObject(0x0)) 1 1
SORT QModelIndex(-1,-1,0x0,QObject(0x0)) 2 2

I've inserted three rows only but rowsInserted emitted four times. Why?

I figured out with excess rowsInserted signal. But I don't have any ideas why my column doesn't sorted.

What am I doing wrong?

Thanks.


--
Best Regards,
Igor Mironchik.

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to