jpujolf
20th February 2009, 12:55
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 :
void Export_XLS ()
{
<stuff>
for ( int iRow = 0; iRow < m_GridModel->rowCount (); iRow++ )
ExportRow ( m_GridModel->index ( iRow, 0 ) );
<more stuff>
}
void ExportRow ( const QModelIndex & index )
{
<...export data for this row...>
if ( !m_Tree->isExpanded ( index ) ||
!m_GridModel->hasChildren ( index ) ) return;
// Recursive call
for ( int iChild = 0; iChild < m_GridModel->rowCount ( index ); iChild++ )
ExportRow ( index.child ( iChild, 0 ) );
}
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 ?
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 :
void Export_XLS ()
{
<stuff>
for ( int iRow = 0; iRow < m_GridModel->rowCount (); iRow++ )
ExportRow ( m_GridModel->index ( iRow, 0 ) );
<more stuff>
}
void ExportRow ( const QModelIndex & index )
{
<...export data for this row...>
if ( !m_Tree->isExpanded ( index ) ||
!m_GridModel->hasChildren ( index ) ) return;
// Recursive call
for ( int iChild = 0; iChild < m_GridModel->rowCount ( index ); iChild++ )
ExportRow ( index.child ( iChild, 0 ) );
}
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 ?