Results 1 to 6 of 6

Thread: list view item problem..

  1. #1
    Join Date
    May 2009
    Posts
    129

    Default list view item problem..

    Hi Friends..

    I am having some number of items in my list....

    That items i am going to display in list view.....

    But it is showing half of the number of items only ...remaining items are empty...

    Qt Code:
    1. for(int i =0;i<list.size();i++)
    2. {
    3.  
    4. QStandardItem *item = new QstandardItem;
    5. model->appendRow(item);
    6.  
    7. }
    8. ui->listView_2->setModel(model);
    9. for(int i =0;i<list.size();i++)
    10. {
    11. statusUser = list.takeFirst();
    12. // QMessageBox::information(0,"name",QString(statusUser->user.name));
    13. t = new Tweet(statusUser->user.name,statusUser->status.text,statusUser->user.profileImageUrl);
    14. model->item(i)->setSizeHint(t->size());
    15. t->resize(ui->listView_2->size().width()+50, t->size().height());
    16. ui->listView_2->setIndexWidget(model->item(i)->index(), t);
    17. }
    To copy to clipboard, switch view to plain text mode 

    How do solve this problem...


    Thanks

    Addu


    Thanks

    Yuvaraj R

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: list view item problem..

    It's because of takeFirst() method. It takes the first element so it means it removes it from the list. Let's say you have 20 items at the begining then:
    1. first loop pass:
    i = 0,
    size() = 20
    2. second loop pass:
    i = 1
    size() = 19

    ...
    10.
    i = 9;
    size() = 11;

    11.
    i = 10;
    size() = 10
    end of loop.

    Use .at(i) instead.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  3. #3
    Join Date
    May 2009
    Posts
    129

    Default Re: list view item problem..

    Thanks

    I read the documents....Your way is exactly correct..

    But for me ...,Qt showing no member named as at ,if i use list.at[i]..

    here i descibe the full function.
    Qt Code:
    1. void Widget::DisplayList(QLinkedList<Returnables::StatusUser*> list, QString header)
    2. {
    3. Returnables::StatusUser *statusUser =NULL;
    4.  
    5. model = new QStandardItemModel(this);
    6. for(int i=0;i<=list.size();i++)
    7. {
    8. //QMessageBox::information(0,"",QString::number(i),QString::number(list.size()));
    9.  
    10. model->appendRow(item);
    11. }
    12. ui->listView_2->setModel(model);
    13.  
    14. for(int i=0;i<=list.size();i++)
    15. {
    16. statusUser = list.at(i);
    17. //QMessageBox::information(0,"name",QString(list[i]));
    18. t = new Tweet(statusUser->user.name,statusUser->status.text,statusUser->user.profileImageUrl);
    19. model->item(i)->setSizeHint(t->size());
    20. t->resize(ui->listView_2->size().width()+50, t->size().height());
    21. ui->listView_2->setIndexWidget(model->item(i)->index(), t);
    22. }
    23. }
    To copy to clipboard, switch view to plain text mode 

    And also it printint the half tweets is same..

  4. #4
    Join Date
    May 2009
    Posts
    129

    Default Re: list view item problem..

    Sorry ..


    Here i am using Qlinked list...It didn't support at member function.

  5. #5
    Join Date
    May 2009
    Posts
    129

    Default Re: list view item problem..

    Hi

    I don't know how solve this issue...

    In API they have used the linked list..

    please help me

  6. #6
    Join Date
    May 2009
    Posts
    129

    Default Re: list view item problem..

    Hi Friends ..

    Still i am struggling with listview items....

    please help us

Similar Threads

  1. expanding tree view problem
    By joeld42 in forum Qt Programming
    Replies: 4
    Last Post: 8th May 2009, 21:52
  2. graphics view FitInView problem
    By aamer4yu in forum Qt Programming
    Replies: 6
    Last Post: 25th January 2007, 11:24
  3. Custom widget in list view
    By fusoin23 in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2006, 15:09
  4. problem with tree view
    By boss_bhat in forum Newbie
    Replies: 4
    Last Post: 4th June 2006, 22:03
  5. View update problem
    By prakash in forum Qt Programming
    Replies: 6
    Last Post: 17th March 2006, 11:13

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.