Results 1 to 3 of 3

Thread: QAbstractListModel - QListView not actualized continously..

  1. #1
    Join Date
    Dec 2011
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QAbstractListModel - QListView not actualized continously..

    Hello,

    I wrote my own read-only model

    webPageModel.h

    class webPageModel : public QAbstractListModel {

    Q_OBJECT

    public:

    webPageModel(QList<wPage *> * st, QObject *parent = 0) : QAbstractListModel(parent) {
    pagesList = st;
    show();

    }

    int rowCount(const QModelIndex &parent = QModelIndex()) const;
    QVariant data(const QModelIndex &index, int role) const;



    private:
    QList<wPage *> * pagesList;
    };



    webPageModel.cpp

    int webPageModel::rowCount(const QModelIndex &parent) const {
    return pagesList->count();
    }

    QVariant webPageModel::data(const QModelIndex &index, int role) const {

    if (!index.isValid())
    return QVariant();

    if (index.row() >= pagesList->size())
    return QVariant();

    if (role == Qt:isplayRole)
    return pagesList->at(index.row())->getUrl().toString();
    else
    return QVariant();
    }


    Timeline
    I create list
    I create model
    view is connected to model
    then I am adding elements to list

    the problem is, that in time when I am creating model, pagesList is empty. Elements in pagesList are added continuously after I create model.
    So View stays empty, until process that fills pagesList stops, than view shows elements all at once (absolutely don't know why, is view doing some automatic? because pointer pagesList does not change with time).

    I would be happy if elements can be added to qlistview concurently with adding to pagesList, and dont know how.

    It will be working if I add list directly into model? (now there is just pointer to the list)
    I suppose there is needed some singals/slot/emit magic?

    Can somebody explain or give some good example? I read http://developer.qt.nokia.com/doc/qt...ogramming.html but without success..

    Thanks

  2. #2
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    2

    Default Re: QAbstractListModel - QListView not actualized continously..

    I only have a good example for you...
    http://developer.qt.nokia.com/doc/qt...ogramming.html

  3. #3
    Join Date
    Dec 2011
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QAbstractListModel - QListView not actualized continously..

    added reset() into model::insert() method in model

Similar Threads

  1. Play continously updated QBuffer with Phonon
    By Skinney in forum Qt Programming
    Replies: 4
    Last Post: 1st December 2011, 18:45
  2. Replies: 6
    Last Post: 30th December 2010, 11:19
  3. Playing 2 wav files continously
    By HanyM.Magdy in forum Qt Programming
    Replies: 3
    Last Post: 5th October 2010, 16:11
  4. reading Continously from QTextStream
    By babu198649 in forum Newbie
    Replies: 2
    Last Post: 2nd December 2008, 11:15
  5. Continously Scroll QPlainTextEdit
    By GimpMaster in forum Newbie
    Replies: 2
    Last Post: 12th September 2008, 17:35

Tags for this Thread

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.