November 9, 2010

Ashwin Das Ashwin Das
Lab Rat
33 posts

Plan for QAbstractItemModel::span ?

 

In the documentation of QAbstractItemModel, I can find this:

QSize QAbstractItemModel::span ( const QModelIndex & index ) const [virtual]
Returns the row and column span of the item represented by index.
Note: Currently, span is not used.

Currently to achieve span in QTableView I am using
void QTableView::setSpan ( int row, int column, int rowSpanCount, int columnSpanCount )

but this is not the right way, as this has to be done from the model,
Doing on the view, I have to handle the span when the rows are sorted or columns moved around, as the span remains in the same place, but the data moves around.

To ensure that the span is linked to the data it was meant to be for, it has to come from the model.

Is there anyway to achieve span, wherein the span moves when sorted or filter etc, with the data.
When is the plan to implement the span method in QAbstractItemModel?

6 replies

November 9, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts

see this bug: http://bugreports.qt.nokia.com/browse/QTBUG-6508 [bugreports.qt.nokia.com]

November 9, 2010

Ashwin Das Ashwin Das
Lab Rat
33 posts

@chetankjain: thanks for the update

November 9, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts

ashwin, wanna try implementing the span() method in QAbstractItemModel? :)

November 9, 2010

Volker Volker
Ant Farmer
5428 posts

chetan: that would be easy :-)

  1. return QSize(1,1);

That’s what the view classes assume at the moment. QTreeView could ignore the setting (as it does not support spans today). But the table view classes would definitely profit from it. I missed it too.

March 8, 2012

jc-denton jc-denton
Lab Rat
36 posts

Hrmm the last entry from the bug report is from 2009 :( In Qt 4.8 the docs for QAbstractItemModel (why don’t they put it in QAbstractTableModel??) still says:

  1. QSize QAbstractItemModel::span ( const QModelIndex & index ) const [virtual]
  2. Returns the row and column span of the item represented by index.
  3. Note: Currently, span is not used.

So I guess I have to work around this.. what’s the best way?

March 8, 2012

jc-denton jc-denton
Lab Rat
36 posts

What about extending QTableView and then implement span(..)? I haven’t extended any QtView class so far..

 
  ‹‹ How to retrieve a HTML page ?      DOM classes: Question about the design ››

You must log in to post a reply. Not a member yet? Register here!