开发者

What happens to QVector's item when it's deleted elsewhere?

开发者 https://www.devze.com 2023-03-07 17:03 出处:网络
I\'m wondering about what happens when I delete a QVector\'s item? Is it automatically removed from the

I'm wondering about what happens when I delete a QVector's item?

  1. Is it automatically removed from the QVe开发者_如何转开发ctor?
  2. Do I have to remove it manually?

Also, how can I find out the index of an iteration of the iterator?

Best regards


If you have a QVector<Thing*> and delete one of the Things that stored in it, it will not be removed automatically from the vector. You need to do that yourself.

As far as I know, and from what I read in the docs, none of the QVector iterators has a method to tell at what index it is positioned.

But if you have a reference to the vector itself (or at least to it's begin() iterator), you can use:

int position = iter - v.begin();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号