Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QString throws bad_alloc Exception

I've got a problem. I use the following Code to convert a std::string into a QString.

std::string testStdStr = "Hello";
QString test = QString::fromStdString(testStdStr);

This code throws a bad_alloc exception unter MSVC 2013 Prof, but only in DEBUG Mode! If I compile in Release Mode everything works as expected.

Some Additional Information: SUBSYSTEM is changed to Windows AND the Entry Point is set to mainCRTStartup

The exception is thrown at the point of initialization of the QString Object! Any suggestions? If you need additional Information, just ask!

like image 839
Kevin H. Klein Avatar asked Sep 13 '25 22:09

Kevin H. Klein


1 Answers

This happens when you mix debug libraries and release libraries, check that all the libraries you link are in debug version (qt5cored.lib [not qt5core.lib], qtmaind.lib etc...)

like image 59
Nadir Avatar answered Sep 16 '25 14:09

Nadir