Results 1 to 5 of 5

Thread: QList: unexplicable crash

  1. #1
    Join Date
    Nov 2009
    Location
    Argentina
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QList: unexplicable crash

    Hi everybody,
    I'm having problems when using QList to generate run-time widgets. I create those widgets and store them inside the QList for later use.
    In one of my dialogs I need to create one QSpinBox and one QLineEdit dynamically. When I create them, everything works fine, and they are shown, but when I close the dialog, the application crashes. Here's the explanation of what I'm doing:

    I create in my header file the QList variable as following:

    private:
    QList<QLineEdit*> products;

    And I use it in in the source file like this:
    QLineEdit *qleProducts = new QLineEdit();
    qleProducts->setCompleter(completer); //Sets widget custom completer, defined before, it works OK
    layout->addWidget(qleProducts); //Adds the widget to a layout
    products.append(qleProducts);

    Then, compile, and everything works OK.
    But the problem comes when I try to create another QList object.
    In the header file I add:
    QList<QSpinBox*> totals;

    And in the source file:
    QSpinBox *qsbTotals= new QSpinBox();
    layout->addWidget(qsbTotals);
    totals.append(qsbTotals);

    Then, I compile the application, it compiles OK, I execute the dialog, creates and display the widgets OK, but when I close the dialog, the application crashes, returning code -1073741819 but no other error.

    It seems that the program crashes when I have declared two QList variables in one file.
    Maybe it is a QT bug, or I'm just missing something stupid.
    Please, I need help, I really need to solve this.

    I'm sorry for my poor English, I'm Argentinian.
    Best regards,
    Facundo

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QList: unexplicable crash

    Don't see why what you described won't work. Can you post your project as an attachment?

  3. #3
    Join Date
    Nov 2009
    Location
    Argentina
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QList: unexplicable crash

    Quote Originally Posted by norobro View Post
    Don't see why what you described won't work. Can you post your project as an attachment?
    Thanks for answering!
    Ok, I'll post it tomorrow, now I haven't the project in this computer.
    Greetings,
    Facundo

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QList: unexplicable crash

    Possible double free issue? Are you delete'ing those objects yourself as it seems they have no parent. If so, remove that code and see if it still crashes.

  5. #5
    Join Date
    Nov 2009
    Location
    Argentina
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QList: unexplicable crash

    Hi,
    First of all, I want to thank both of you for answering, I solved the problem, (although don't know HOW). I changed the code a little and then rebooted my computer and WORKED!
    I don't know what could it be.
    Kind regards,
    Facundo

Similar Threads

  1. Copying an QList into a new, sorted QList.
    By Thomas Wrobel in forum Newbie
    Replies: 3
    Last Post: 11th January 2010, 19:27
  2. crash at QList<MyControls *> handling
    By navid in forum Newbie
    Replies: 4
    Last Post: 4th November 2009, 16:40
  3. program crash on signalMapping QList
    By wagmare in forum Qt Programming
    Replies: 4
    Last Post: 22nd July 2009, 17:23
  4. QList: Out of memory - without having defined QList
    By miroslav_karpis in forum Qt Programming
    Replies: 1
    Last Post: 27th March 2009, 09:42
  5. QList crash in destructor
    By mclark in forum Newbie
    Replies: 7
    Last Post: 6th December 2006, 16:27

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.