×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    32

    How to add more items in QListWidget

    Hi all,

    How to add more items in QListWidget ?

    Below is the code I am using, it gives error as "memory full" in device (N8)

    void gotItem(IndividualSearchData *item)
    {

    Cell* cell = new Cell();
    cell->setTitle(item->m_Title);
    cell->setDescription(item->m_ShortDescription);
    cell->setImage(item->m_IconURL);
    connect(cell,SIGNAL(imageButtonClicked(QPixmap)),this,SLOT(previewImage(QPixmap)));
    QListWidgetItem *dataItem= new QListWidgetItem(ui->listWidget);

    dataItem->setSizeHint(QSize(430,189));
    ui->listWidget->addItem(dataItem);
    ui->listWidget->setItemWidget(dataItem,cell);

    }


    Cell is a sub class of of QWidget and contains three labels "title", "discription" and pass url as parameter.

    The cell download the image from this url.

    The gotItem method is called for about 400-500 times(whenever we get data from server)

    I checked with memory, it keeps on increasing, but how to reduce this ?

    Please let me know how to achieve this.


    Thanks in advance

    siddu

  2. #2
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    142

    Re: How to add more items in QListWidget

    What is the size of images? You can try using scaled down image instead of full sized image.

  3. #3
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: How to add more items in QListWidget

    Images take a lot of space.

  4. #4
    Registered User
    Join Date
    Dec 2010
    Posts
    32

    Re: How to add more items in QListWidget

    Hi

    Thanks for the quck reply,

    I tried even by commenting downloading image code, I mean now I am not dowloading the imag, sill it increases the memory,

    Here how do I handale the memory allocated for "Cell" and "item" object (with reference to my prev mail), because each time it keep on creating.
    I know that memory for item (QListWidgetItem) will be handaled by its parent (listwidget), but liswidget will delete all the items in it when listwidget itself is deleted.

    Please help me, I am struggling with past two days. with no clue


    Thanks
    Siddu

  5. #5
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: How to add more items in QListWidget

    500 items in a list widget is a lot, even without images. I would guess that each item consumes 1-2K of heap, but I could be off by a factor of ten.

    And what about the storage associated with those 500 messages you've received -- is that being properly recycled?

  6. #6
    Registered User
    Join Date
    Dec 2010
    Posts
    32

    Re: How to add more items in QListWidget

    Hi

    Even I checked with 150 of items, it takes lot of memory.

    All the data(messages) receieved will be saved in an object (IndividualSearchData object) from this object data will be set to cell (title,discription).
    Previously I worked with iPhone, it is smooth there..


    Thanks
    Siddu

  7. #7
    Registered User
    Join Date
    Dec 2010
    Posts
    32

    Re: How to add more items in QListWidget

    Hi ,

    Please let me know is there any thing wrong with the code

    Any help, suggestion are most well come.

  8. #8
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: How to add more items in QListWidget

    Well, you can increase the heap size, you know. It easily can be 4x bigger than the default.

    But I gotta wonder how usable a list with 500 items is.

  9. #9
    Registered User
    Join Date
    Dec 2010
    Posts
    32

    Re: How to add more items in QListWidget

    Hi

    500 items can be changed to some were 100,

    but how do you increase the heap size, does it not affect while running in device ?

    Thanks,
    Siddu

  10. #10
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: How to add more items in QListWidget

    Well, increasing heap size is device-dependent, and presumably you're not running on Maemo or Symbian or you'd have posted in one of those forums, so I can't tell you.

  11. #11
    Registered User
    Join Date
    Dec 2010
    Posts
    32

    Re: How to add more items in QListWidget

    Hi

    I am running it on N8, and
    I have posted the same question in qt-interest@qt.nokia.com, is there any problem ?

  12. #12
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: How to add more items in QListWidget

    Well, N8 is Symbian, so presumably you should be in "Qt for Symbian". "Qt SDKs and Tools" is for questions about (duh!) SDKs and tools, not actual Qt programming issues.

    But if you'd spent a little time with Google you'd already know how to increase heap size.

  13. #13
    Registered User
    Join Date
    Dec 2010
    Posts
    32

    Re: How to add more items in QListWidget

    Hi,

    Thanks,
    I did not know,
    Now Can I post the same question there ?
    I believe it should not be a problem.
    If you say yes , then I will post there


    Thanks,

Similar Threads

  1. How can i select multi items in QListWidget?
    By SaiPrasad2010 in forum Qt
    Replies: 0
    Last Post: 2010-12-28, 05:37
  2. Replies: 6
    Last Post: 2010-12-03, 14:46
  3. Multiline items in QListWidget
    By pavel_turbin in forum Qt
    Replies: 2
    Last Post: 2010-07-10, 20:26
  4. QListWidget - owner drawn items
    By tamhanna in forum Qt
    Replies: 4
    Last Post: 2010-04-28, 09:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×