Transaction not applied

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
User avatar
andrew
Site Admin
Posts: 9059
Joined: Fri Mar 30, 2007 6:07 am

Transaction not applied

Post by andrew » Mon Mar 07, 2016 9:56 am

From a QCAD user:
I'm trying to run a transaction but it has no effect:
...
RTransaction t(document.getStorage(), QObject::tr("Set Layer Properties"));
layer->setFrozen(false);
layer->setLocked(false);
t.addObject(layer, false);
t.end();
...

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

Re: Transaction not applied

Post by andrew » Mon Mar 07, 2016 10:03 am

Transactions are usually only used on a lower level in QCAD (a transaction records all changes on a set of objects caused by an operation, i.e. when adding, deleting or modifying objects).

Operations are the concept used for more comfortable, higher level modifications:
RModifyObjectsOperation op;
op.addObject(layer);
di->applyOperation(&op);
This will update the document and also the views, layer lists, etc. accordingly. A transaction object is returned by applyOperation which contains information about objects that were changed.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”