Results 1 to 4 of 4

Thread: error with QList<my_labels *> handling

  1. #1
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default error with QList<my_labels *> handling

    Hello

    my application crash with the following error:

    ASSERT failure in QList<T>::at: "index out of range", file c:/Qt/2009.04/qt/include/QtCore/../../src/corelib/tools/qlist.h, line 395

    ================================================
    //header
    struct my_labels
    {
    QLabel * label_a;
    QLabel * label_b;
    QLabel * label_c;
    };

    private:
    QList<my_labels *> my_labels_list;

    //cpp
    my_labels_list.clear();;
    my_labels_list.at(0)->label_a = ui->label1; //<- error

    ==========================================
    i going to have a list of (pointer to) my labels widgets

    i will be appreciated with your comments in this regard.
    n navid

  2. #2
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: error with QList<my_labels *> handling

    if you remove all the items from your list and you try to access to them, of course it's going to crash :P

    Qt Code:
    1. my_labels_list.clear();
    2. //fill your list first!!!!
    3. my_labels_list << label_a;
    4. my_labels_list << label_b;
    5. my_labels_list << label_c;
    6. my_labels_list[0] = ui->label1
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: error with QList<my_labels *> handling

    thanks
    navid

  4. #4
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: error with QList<my_labels *> handling

    agh! sorry; don't use [], use QList::insert instead.

Similar Threads

  1. Suggested Error Handling
    By Max Yaffe in forum Qt Programming
    Replies: 6
    Last Post: 15th July 2014, 17:29
  2. large file handling
    By sakthi in forum Qt-based Software
    Replies: 1
    Last Post: 30th October 2008, 00:34
  3. Special Character Handling
    By Kubil in forum Qt Programming
    Replies: 1
    Last Post: 22nd June 2008, 22:58
  4. Exception handling in Qt 4.2.2
    By vishal.chauhan in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2007, 09:47
  5. need help for tree Handling concept
    By jyoti in forum Qt Programming
    Replies: 5
    Last Post: 24th November 2006, 04:52

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.