简体   繁体   中英

Fast changing QLineEdit crashing the application

I have three QLineEdit fields, whose content is changing really fast (100/second). Somehow it crashes the application. Maybe it's a bug or I make a mistake.

Here is some code:

acc[0]->setText(QString("%1").arg(acceleration.x));
acc[1]->setText(QString("%1").arg(acceleration.y));
acc[2]->setText(QString("%1").arg(acceleration.z));

The call stack: http://pastebin.com/RmkZHTjk

And sometimes I get this error:

Unhandled exception at 0x6518cbb3 (QtGuid4.dll) in Test.exe: 0xC0000005: Access violation reading location 0x0000002c.

Call stack for this: http://pastebin.com/c1u53a0Z

I tried it with QLabel, then I get another error:

Unhandled exception at 0x751a9617 in Test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x03aeea70..

Call stack: http://pastebin.com/G4yeiW2Y

Lets get this closed. This is Frank's answer posted as comment a week ago.

@Roland Soós: It looks to me like you call setText() from the non-UI thread. That won't work, QWidgets are not thread-safe. -- Frank

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM