Refresh a widget

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
RR88
Full Member
Posts: 51
Joined: Sun Apr 29, 2018 7:04 am
Location: Leinefelde

Refresh a widget

Post by RR88 » Tue Oct 16, 2018 8:35 am

I removed some layers by a script and they are still visible in the layer list. How can I refresh/update the widget manually?
Arch Linux, QCad 3.22.0 Prof.

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

Re: Refresh a widget

Post by andrew » Tue Oct 16, 2018 9:00 am

If you remove the layers using RDeleteObjectOperation, the layer list will be updated. See RemoveLayer for an example:
https://github.com/qcad/qcad/blob/maste ... veLayer.js

RR88
Full Member
Posts: 51
Joined: Sun Apr 29, 2018 7:04 am
Location: Leinefelde

Re: Refresh a widget

Post by RR88 » Tue Oct 16, 2018 9:18 am

I found out, that it works only when I set undoable to true. Is there any workaround?

This is my code:

Code: Select all

var op = new RDeleteObjectsOperation(false);

layers.forEach(function (name) {
    var lay = doc.queryLayer(name);
    op.deleteObject(lay);
});

di.applyOperation(op);
Arch Linux, QCad 3.22.0 Prof.

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

Re: Refresh a widget

Post by andrew » Wed Oct 17, 2018 8:52 am

Making operations not undoable (argument false) means transactions are not recorded. However, the layer list and other widgets are rely on transactions to update themselves. Not undoable operations should only be used for offscreen documents that don't offer any form of user interaction at all.

RR88
Full Member
Posts: 51
Joined: Sun Apr 29, 2018 7:04 am
Location: Leinefelde

Re: Refresh a widget

Post by RR88 » Tue Oct 23, 2018 5:16 pm

Okay, thanks for the answer.
Arch Linux, QCad 3.22.0 Prof.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”