Hi Andrew,
Is there a listener which I can use (c++) which notifies me when a user creates a new drawing or opens an existing one?
I have hooked into RFocusListener but this seems to only get called if the user has more than one drawing open and they switch tabs (selecting one drawing then the other...).
Thanks,
Andrew.
Edit: Okay after some further testing it does seem to notify me when the user creates a new drawing or opens an existing drawing.
Where it is failing is when you launch QCad; I am not being notified the default drawing (the one which is auto created on launch) has been created. I am guessing this is because my C++ plugin which has the RFocusListner in has not been initialised?
Notified when file created or opened
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Re: Notified when file created or opened
Listeners for this have been added in the current development version of QCAD:Taygete wrote:Is there a listener which I can use (c++) which notifies me when a user creates a new drawing or opens an existing one?
https://github.com/qcad/qcad/blob/maste ... Listener.h
https://github.com/qcad/qcad/blob/maste ... Listener.h
Yes, this has also changed for this reason. Plugins are now being notified at various stages while QCAD is loading:Where it is failing is when you launch QCad; I am not being notified the default drawing (the one which is auto created on launch) has been created. I am guessing this is because my C++ plugin which has the RFocusListner in has not been initialised?
The postInit method of your plugins is now called four times in this order with a status argument:
- When the main window is available (no documents open yet)
- Files given on the command line have been loaded, respectively, a new empty document has been created
- Scripts passed on the command line have been executed
- All work has been done and QCAD is ready to receive user input
If you want to register a listener, best do it when postInit is called with status==RPluginInterface::GotMainWindow.
Re: Notified when file created or opened
Thanks Andrew, I will take a look over the weekend, I did find a workaround but will implement your method instead.
Andrew.
Andrew.