How to use QThread in ECMAScript code?

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
fang_h_y
Newbie Member
Posts: 8
Joined: Sat Jul 14, 2018 4:15 am

How to use QThread in ECMAScript code?

Post by fang_h_y » Tue Aug 14, 2018 1:25 pm

Hello.

I want to set a new thread to compute. Because compute costs a lot of time so I want to set a new thread. But when I use
var thread = new QThread();
The console tell me that "Can't find variable: QThread".
How should I do to realize it?

Thank you very much.
fang_h_y

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: How to use QThread in ECMAScript code?

Post by andrew » Thu Aug 23, 2018 3:36 pm

Some of the Qt API (including QThread) is not available for scripts. This likely means it would cause problems.

fang_h_y
Newbie Member
Posts: 8
Joined: Sat Jul 14, 2018 4:15 am

Re: How to use QThread in ECMAScript code?

Post by fang_h_y » Sat Sep 29, 2018 3:01 am

Hello,andrew

Is there anyway way to solve this problem? I want to do some function that spend a lot of time in other thread. If realize the function in GUI thread, it will block the GUI thread.

Look forward your reply
fang_h_y

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: How to use QThread in ECMAScript code?

Post by andrew » Fri Oct 05, 2018 3:12 pm

You could call QCoreApplication.processEvents(); in your loop to keep the GUI responsive.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”