Results 1 to 4 of 4

Thread: Custom Model Help PLz

  1. #1
    Join Date
    Aug 2007
    Posts
    4
    Thanks
    1

    Smile Custom Model Help PLz

    Hi, i need help with my custom model( from http://www.qtcentre.org/forum/f-qt-p...king-8296.html )

    My listview is always empty...

    The bugged model = RemoteModel
    Attached Files Attached Files

  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: Custom Model Help PLz

    Please, next time you attach a test project, make sure it at least compiles. Also, please try to be more specific with problem description. I can see more than one list view in your application.

    The problem does not lie within RemoteModel but in the way it's being used:
    Qt Code:
    1. void MainWindow::addToList(const QUrlInfo & urlInfo) {
    2. ...
    3. // ftp_model->setData(ftp_model->index(-1), &addMe); // <-- WRONG
    4. ftp_model->setData(ftp_model->index(0), QVariant::fromValue(addMe));
    5. ...
    6. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. #3
    Join Date
    Aug 2007
    Posts
    4
    Thanks
    1

    Default Re: Custom Model Help PLz

    Thank very much... but my list still empty

    I've post a compilable project.

    The empty list is called lstFileRemote ( le right treeview )
    The bugged model RemoteModel
    The List is populated in this method (from a ftp connection) :



    Qt Code:
    1. void MainWindow::addToList(const QUrlInfo & urlInfo) {
    2. RemoteModel::FileList addMe;
    3. addMe.name = urlInfo.name();
    4. addMe.size = QString::number(urlInfo.size());
    5. ftp_model->insertRows(0, 1);
    6. ftp_model->setData(ftp_model->index(-1), QVariant::fromValue(addMe));
    7. }
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files

  4. #4
    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: Custom Model Help PLz

    Take a closer look at the changes. Do not set data at index -1 but at index 0.
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    Simz (16th August 2007)

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. Coin3d + Qt: SIGLNALs and SLOTs
    By vonCZ in forum Newbie
    Replies: 26
    Last Post: 15th May 2009, 07:34
  3. Help with getting my custom model working
    By thomaspu in forum Qt Programming
    Replies: 19
    Last Post: 29th July 2007, 18:35
  4. Treeview and custom model
    By steg90 in forum Qt Programming
    Replies: 8
    Last Post: 15th May 2007, 13:54
  5. TreeView custom model
    By steg90 in forum Newbie
    Replies: 1
    Last Post: 9th May 2007, 10:06

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.