Maya QString fromStdString

Maya QString fromStdString

Anonymous
Not applicable
925 Views
1 Reply
Message 1 of 2

Maya QString fromStdString

Anonymous
Not applicable

Hi so I am using QString from maya, and I am having this issue that if I call the function: QString::fromStdString(...)   it causes some access violation crash:

- "Attempted to write to protected memory"

 

However, if I call the function QString::fromAscii(...)  it does not crash.

 

 

 

Example of crash:

 

QString test = QString::fromStdString("test");

 

 

Example non crash:

 

QString test = QString::fromAscii("test");

 

 

Anyone have any ideas why?

0 Likes
926 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

Actually in my app it doesn't crash. However fromStdString wants and std::string reference, usually it should implicitly convert to std::string from a char*, but you could try to explicitly create a std::string.

 

QString test = QString::fromStdString(std::string("Test"));

0 Likes