简体   繁体   English

快速更改的QLineEdit使应用程序崩溃

[英]Fast changing QLineEdit crashing the application

I have three QLineEdit fields, whose content is changing really fast (100/second). 我有三个QLineEdit字段,它们的内容变化非常快(100 /秒)。 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 调用堆栈: 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. Test.exe中0x6518cbb3(QtGuid4.dll)的未处理异常:0xC0000005:访问冲突读取位置0x0000002c。

Call stack for this: http://pastebin.com/c1u53a0Z 为此调用堆栈: http : //pastebin.com/c1u53a0Z

I tried it with QLabel, then I get another error: 我用QLabel尝试过,然后又遇到另一个错误:

Unhandled exception at 0x751a9617 in Test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x03aeea70.. Test.exe中0x751a9617处未处理的异常:Microsoft C ++异常:内存位置0x03aeea70处的std :: bad_alloc。

Call stack: http://pastebin.com/G4yeiW2Y 调用堆栈: http//pastebin.com/G4yeiW2Y

Lets get this closed. 让我们关闭它。 This is Frank's answer posted as comment a week ago. 这是弗兰克(Frank)一周前发表的评论。

@Roland Soós: It looks to me like you call setText() from the non-UI thread. @RolandSoós:在我看来,就像您从非UI线程调用setText()一样。 That won't work, QWidgets are not thread-safe. 那是行不通的,QWidgets不是线程安全的。 -- Frank -弗兰克

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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