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?





  • @chetankjain: thanks for the update



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



  • chetan: that would be easy :-)

    @
    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.



  • 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:

    @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.@

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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.