Receiving signal when creating new Document

  • Dear all,

    I'm trying to catch the signal when a new document is created. On my app constructor, I connect to the following slots:

    SAMSON::getActiveLayer()->connectDocumentSignalToSlot(this, SB_SLOT(&MyApp::onDocumentEvent));
      SAMSON::getActiveDocument()->connectDocumentSignalToSlot(this, SB_SLOT(&MyApp::onDocumentEvent));

    This way I can catch for example when a new layer is created, or when my document is closed. But this code remains oblivious to the creation of a new document, and thus whenever one is created I am unable to update my signal connections and events coming from the new document are not fetched by my app.

    I'm trying to use this to do some operations in my app when loading a custom model thorugh a .sam file (I implemented serialization and unserialization).

    Thank you for your help and best regards,


  • Dear @Elisa

    Here you connect signal to slots for pointers of a current active layer and a current active document. There is no possibility now to listen to an event of the creation of a new document.

    Do I understand correctly that you want for your App to do some operations automatically once a .sam file was imported?

    What you can do is to create a timer in your App and connect to it a function in which you will be doing something like this:

    if(SAMSON::getActiveDocument()->documentSignalIsConnectedToSlot(this, SB_SLOT(&MyApp::onDocumentEvent)) == false) {
        SAMSON::getActiveDocument()->connectDocumentSignalToSlot(this, SB_SLOT(&MyApp::onDocumentEvent));

  • Dear @Elisa, we will expose these signals in 0.8.0.

  • Thank you both, I will use the timer as a workaround for now.

    Seems 0.8.0 is going to have a lot of interesting changes :)

Log in to reply

Looks like your connection to SAMSON Connect - Forum was lost, please wait while we try to reconnect.