不知道算不算QT的BUG,请大佬解答

  • QT 6.6.0
  • msvc2019_64

个人觉得QT的容器应该都有这个问题

使用QList程序崩溃

#include 
#include 

int main(int argc, char* argv[]) {
	QList<QPushButton*> buttons;
	buttons.push_back(new QPushButton());
	buttons.push_back(new QPushButton());
	for (QList<QPushButton*>::iterator it = buttons.begin(); it != buttons.end();) {
		QPushButton* widget = *it;
		widget->deleteLater();
		buttons.erase(it++);/* Really smart! */
	}
}

使用标准库std::list没有任何问题

#include 
#include 

int main(int argc, char* argv[]) {
	std::list<QPushButton*> buttons;
	buttons.push_back(new QPushButton());
	buttons.push_back(new QPushButton());
	for (std::list<QPushButton*>::iterator it = buttons.begin(); it != buttons.end();) {
		QPushButton* widget = *it;
		widget->deleteLater();
		buttons.erase(it++);/* Really smart! */
	}
}

你可能感兴趣的:(QT,qt,bug,开发语言)