Results 1 to 2 of 2

Thread: QListView does not display its model

  1. #1
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QListView does not display its model

    I have met an odd obstacle.
    QListView does not display my subclass of QAbstractListModel even though everything is done as usually (I suppose).
    //Model subclass
    http://www.mjakobczyk.pl/pub/hostInfoModel.hpp
    http://www.mjakobczyk.pl/pub/hostInfoModel.cpp
    //Data
    http://www.mjakobczyk.pl/pub/hostInfo.hpp
    http://www.mjakobczyk.pl/pub/hostInfo.cpp

    Usage is as follows:
    In constructor:
    hostInfoModel = new HostInfoModel(hostList,this);
    listView = new QListView;
    listView->setModel(hostInfoModel);

    User clicks "refresh list" button that is followed by 10 secs of udp hunting.
    Each diffrent packet is parsed and MTR::HostInfo are created and placed into the QList<MTR::HostInfo>.
    It does work.
    Then hostInfoModel->setHostInfoList(hostInfoList);
    It does work as during tests rowCount showed number of MTR::HostInfo objects inside.
    and now I suppose listView should display its model data but the problem is that with qDebug I have found out that MTR::HostInfoModel::data() is not evoked even once.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QListView does not display its model

    HostInfoModel::setHostInfoList() does not inform the model-view framework that the internal data structure changes. You should call for example QAbstractItemModel::reset().

    PS. Attach files on this forum next time instead of linking to external sites, please.
    J-P Nurmi

  3. The following 2 users say thank you to jpn for this useful post:

    akiross (29th February 2008), mtrpoland (22nd February 2008)

Similar Threads

  1. hierarchical model in a flat view
    By gniking in forum Qt Programming
    Replies: 4
    Last Post: 10th November 2009, 20:17
  2. Model Choices review/questions
    By ucntcme in forum Qt Programming
    Replies: 1
    Last Post: 16th September 2007, 21:57
  3. QListView word wrap
    By serega in forum Qt Programming
    Replies: 17
    Last Post: 30th August 2007, 03:13
  4. Subclass QListView to show two colums in one
    By Mookie in forum Qt Programming
    Replies: 2
    Last Post: 23rd June 2007, 02:12
  5. QListView and delegate to display data
    By T4ng10r in forum Qt Programming
    Replies: 5
    Last Post: 30th May 2007, 09:25

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.