Results 1 to 20 of 50

Thread: QVector crashes when array size is big

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2008
    Location
    New York
    Posts
    90
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 4 Times in 4 Posts

    Default Re: QVector crashes when array size is big

    Quote Originally Posted by wysota View Post
    No, it's not. If it were on the stack and you returned from the function the frame of which it would be positioned in, the data would get destructed which is of course not the case.

    What is on the stack is probably the local copy of the structure when push_back is called (although I'm not sure as push_back probably takes a const reference and not a copy).

    Sheng: Why do you need that array there in the first place? Can't you use a vector that dynamically allocates its data as it is needed?

    By the way, if you don't need a vector but a linked list, use QLinkedList and not QVector
    Yes, actually I used linked list, just use QVector for the example since all of them crashes.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default

    Quote Originally Posted by Sheng
    Yes, actually I used linked list, just use QVector for the example since all of them crashes.
    Still you didn't say what is the array meant for.

    Quote Originally Posted by lni View Post
    In his example, the stack is contained inside the heap.
    I'm sorry, but are you sure you know what the stack is? Because based on your post I think you don't.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How to find best size for QTableWidget?
    By plamkata in forum Qt Programming
    Replies: 3
    Last Post: 24th July 2008, 20:07
  2. QT-wince and QHttp::readAll() trouble....
    By AcerExtensa in forum Qt for Embedded and Mobile
    Replies: 6
    Last Post: 12th June 2008, 10:40
  3. QLabel size policy
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2007, 18:57
  4. Replies: 1
    Last Post: 24th October 2006, 17:40
  5. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 23:14

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
  •  
Qt is a trademark of The Qt Company.