Results 1 to 2 of 2

Thread: std::vector

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default std::vector

    I have a vector not (QVector) of pointers to a struct. I am reusing the same window in my project and just clearing the vector and re-populating it when the data changes. The program keeps crashing when I initially try to run the program though, and it's because I am trying to clear a vector that has had nothing done it to. I call the same function when I load new data, and this function wants to clear the vector. I figured there was no harm clearing a vector I hadn't used but apparently this is not so.

    So is there a way to have a vector declared in my .h file, and skip clearing it the first time through, but then clear it after that? Even if I try to check it's size to see if it's greater than 0, it crashes. Thanks for your help.

  2. #2
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: std::vector

    Boy am I feeling stupid. If you never initialize the class containing the vectors, it's a little hard to work with the class's vectors. I am surprised it got that far since the class object was NULL. Oh well, thanks for your help anyways.

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.