Results 1 to 2 of 2

Thread: QAbstractTableModel data insert issues

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2007
    Posts
    19
    Thanks
    5
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default QAbstractTableModel data insert issues

    Im trying to add elements to a QAbstractTableModel via the QVariant data function like so
    Qt Code:
    1. QVariant WTrackTableModel :: data(const QModelIndex &index, int role) const
    2. {
    3. TrackInfoObject *m_pTrackInfo = m_pTrackCollection->getTrack(index.row());
    4. QStringList trackInfoList;
    5. trackInfoList.append(m_pTrackInfo->getScoreStr());
    6. trackInfoList.append(m_pTrackInfo->getTitle());
    7. trackInfoList.append(m_pTrackInfo->getArtist());
    8. trackInfoList.append(m_pTrackInfo->getType());
    9. trackInfoList.append(m_pTrackInfo->getDurationStr());
    10. trackInfoList.append(m_pTrackInfo->getBitrateStr());
    11. trackInfoList.append(m_pTrackInfo->getBpmStr());
    12. trackInfoList.append(m_pTrackInfo->getComment());
    13.  
    14. if (!index.isValid())
    15. return QVariant();
    16.  
    17. if (index.row() >= m_pTrackCollection->getSize())
    18. return QVariant();
    19.  
    20. if (role == Qt::DisplayRole)
    21. return trackInfoList;
    22. else
    23. return QVariant();
    24. }
    To copy to clipboard, switch view to plain text mode 

    This code causes my program to crash. What I'm aiming to do is place the trackinfoobject's various get functions QString information into their respective columns (score, title, artist, etc.) what do I need to change to do so?

    Thanks!
    Last edited by nategoofs; 13th August 2007 at 01:24.

Similar Threads

  1. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.