Qt需要很长时间的编程和计算 [英] Qt Programming and computations which take long time

查看:200
本文介绍了Qt需要很长时间的编程和计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的Qt编程。我必须进行一些需要很长时间的计算。我使用一个编辑框和两个名为开始和停止的按钮。编辑框用于初始化。开始按钮开始计算。当计算正在进行时,我必须能够在我想要的时候停止计算。但是当我通过点击开始按钮开始计算。正如预期,我不能点击窗口上的任何组件,直到计算完成。

I am new on Qt programming. I have to make some computations which take long time. I use an edit box and two button named as "start" and "stop". The edit box is used for the initialization. Start button starts the computation. While the computation is going on, I must be able to stop the computation whenever I want. But when I start the computation by clicking the start button. As expected, I cannot click any component on the window until the computation is completed.

我想在窗口正常使用组件(特别是停止按钮)正在执行。但我不是在线程,我正在寻找一个更容易的方法。有没有简单的解决方案?

I want to use the components (especially stop button) on the window normally while the computation is performing. But I am not good on the threads, I am looking for an easier method. Is there any simple solution?

推荐答案

使用线程(可能通过发送管道上的消息自我同步) a href =http://doc.qt.nokia.com/latest/qobject.html#startTimer =nofollow> timer (0毫秒延迟,这是如何进行空闲处理) Qt)。

Either use threads (perhaps synchronizing them by sending messages on pipes to self), or use timer (with a 0 millisecond delays, this is how idle processing is done in Qt).

这篇关于Qt需要很长时间的编程和计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆