Ok, here is most of the code :
int DATreeModel::rowCount( const QModelIndex& parent ) const
{
int nCount = m_Data.count() / 4;
return nCount;
}
int DATreeModel
::columnCount(const QModelIndex &) const {
return 4;
}
QVariant DATreeModel
::data( const QModelIndex
& index,
int role
) const {
if (!index.isValid())
if (index.row() > (m_Data.size() / 4) ) {
}
if(index.column() > 3 ) {
}
if( role == Qt::DisplayRole )
{
int nPos = index.column() + ( 4 * index.row() );
if( nPos < m_Data.size() )
data = m_Data.at( nPos );
}
return data;
}
void DATreeModel::setCanData( CANDATA *pData, int nAmount, int nCount )
{
if( pData )
{
for( int i = 0; i < nAmount; i++ )
{
m_Data.append(pData[i].strId);
m_Data.append(pData[i].strTime);
m_Data.append(pData[i].strData);
strCount.sprintf( "%i", nCount );
m_Data.append(strCount);
nCount++;
}
}
endInsertRows();
}
int DATreeModel::rowCount( const QModelIndex& parent ) const
{
int nCount = m_Data.count() / 4;
return nCount;
}
int DATreeModel::columnCount(const QModelIndex &) const
{
return 4;
}
QVariant DATreeModel::data( const QModelIndex& index, int role) const
{
QVariant data;
if (!index.isValid())
return QVariant();
if (index.row() > (m_Data.size() / 4) ) {
return QVariant();
}
if(index.column() > 3 ) {
return QVariant();
}
if( role == Qt::DisplayRole )
{
int nPos = index.column() + ( 4 * index.row() );
if( nPos < m_Data.size() )
data = m_Data.at( nPos );
}
return data;
}
void DATreeModel::setCanData( CANDATA *pData, int nAmount, int nCount )
{
beginInsertRows(QModelIndex(), 1, 1);//nAmount );
if( pData )
{
for( int i = 0; i < nAmount; i++ )
{
m_Data.append(pData[i].strId);
m_Data.append(pData[i].strTime);
m_Data.append(pData[i].strData);
QString strCount;
strCount.sprintf( "%i", nCount );
m_Data.append(strCount);
nCount++;
}
}
endInsertRows();
}
To copy to clipboard, switch view to plain text mode
I'm so confused?
Kind regards,
Steve
Bookmarks