Hi all,

I'm confused. Something wrong in my code or a Qt bug ?

I've a QTreeView, showing data as a grid with groups. I've implemented an "export to excel" method, that exports all model's data shown. First attempt worked. I can export all data, not AS shown. If a row is grouped, I export too its children.

Now, Im testing if every node is expanded and I can export only expanded rows, as must be...

Code is like this :

Qt Code:
  1. void Export_XLS ()
  2. {
  3. <stuff>
  4. for ( int iRow = 0; iRow < m_GridModel->rowCount (); iRow++ )
  5. ExportRow ( m_GridModel->index ( iRow, 0 ) );
  6. <more stuff>
  7. }
  8.  
  9. void ExportRow ( const QModelIndex & index )
  10. {
  11. <...export data for this row...>
  12. if ( !m_Tree->isExpanded ( index ) ||
  13. !m_GridModel->hasChildren ( index ) ) return;
  14.  
  15. // Recursive call
  16. for ( int iChild = 0; iChild < m_GridModel->rowCount ( index ); iChild++ )
  17. ExportRow ( index.child ( iChild, 0 ) );
  18. }
To copy to clipboard, switch view to plain text mode 

But now I've seen that only first level of tree is exported, because isExpanded ALLWAYS return false, even if I user expands items on screen or expandall is called.

Why ?