Refresh a widget

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

Moderator: andrew

Post Reply
RR88
Junior Member
Posts: 17
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?
Gentoo/Linux, QCad 3.20 Prof.

User avatar
andrew
Site Admin
Posts: 5641
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
Junior Member
Posts: 17
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);
Gentoo/Linux, QCad 3.20 Prof.

User avatar
andrew
Site Admin
Posts: 5641
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
Junior Member
Posts: 17
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.
Gentoo/Linux, QCad 3.20 Prof.

Post Reply

Return to “QCAD Developers and Contributors”