<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi Lars -</p>
    <p>I hazard a guess, that you want to execute some action after a <i>project</i>
      has finished loading.</p>
    <p>You might have a look on how to execute macro's after open, save
      or close events for the project:</p>
    <p>In the project properties, you can enable macro's and write some
      python code that will be stored in the project:<br>
    </p>
    <p>Example: (Open an attribute window with data from layer 'kommune"
      after the project has finished loading)<br>
    </p>
    <pre><font color="#990000"><code>#--- macro start ---

from qgis.core import QgsProject
from qgis.utils import iface

def openProject():
    layers = QgsProject.instance().mapLayersByName('kommune')
    layer = layers[0]
    iface.showAttributeTable(layer)   

def saveProject():
    pass

def closeProject():
    pass</code><code>

#--- macro end ---</code></font></pre>
    <div class="moz-cite-prefix">Den 21-08-2019 kl. 14:15 skrev Lars I.
      Nielsen, LIFA A/S:<br>
    </div>
    <blockquote type="cite"
      cite="mid:6EDB455314CAD940983B0F3ACAC4B0A53B14D747@Mail2010.LIFA.DK">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <meta name="Generator" content="Microsoft Word 14 (filtered
        medium)">
      <!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]-->
      <style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Markeringsbobletekst Tegn";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";
        mso-fareast-language:EN-US;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Arial","sans-serif";
        color:windowtext;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
span.MarkeringsbobletekstTegn
        {mso-style-name:"Markeringsbobletekst Tegn";
        mso-style-priority:99;
        mso-style-link:Markeringsbobletekst;
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:3.0cm 2.0cm 3.0cm 2.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US">Hi bold developers of QGIS.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US">I’ve recently begun digging into utilizing the
            event (signal) model of QGIS (3.4).<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US">And I’ve encountered a number of frustrations,
            as the events don’t work the way they’re supposed to, at
            least according to the available documentation (<a
              href="https://qgis.org/pyqgis/master/core/index.html"
              moz-do-not-send="true">https://qgis.org/pyqgis/master/core/index.html</a>).<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US">E.g., the event “layerLoaded” on the project
            instance with the description “<i>Emitted when a layer from
              a projects (sic) was read</i>”, which to me indicates,
            that the loading is done (due to the use of “loaded” and
            “was”).<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US">But the event is emitted before the loading of
            the layer is done, and you are therefore unable to find the
            layer it concerns.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US">Another example is the event “metadataChanged”
            on a loaded layer, which again to me indicates a past/done
            action (due to the use of “changed”). But again, it’s
            emitted before the change actually takes place, and the
            changed metadata isn’t available.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US">If the two events are indeed preload events,
            their names should instead be something like “layerLoading”
            and “metadataChanging”, or even “layerPreLoad” and
            “metadataPreChange”.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US">Is there a guide somewhere to tell how the
            event system is envisioned, and which events are emitted
            pre-action and which are emitted post-action ?<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US">Or must I (hopefully not) take a deep look into
            the QGIS source code itself for this kind of information ?<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US">In general, pre-action events are of limited
            use, except when it comes to deletions and destructions. For
            loading and changing stuff, post-action events are almost
            always what you need.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black"
            lang="EN-US">Med venlig hilsen</span><br>
          <br>
          <span
style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black"
            lang="EN-US">Lars I. Nielsen, LIFA A/S</span><br>
          <span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
            lang="EN-US">GIS-konsulent, FME Certified Professional</span><br>
          <span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">Geoinformatik</span><br>
          <span
style="font-size:8.0pt;font-family:"Arial","sans-serif";color:black;mso-fareast-language:DA"><img
              id="_x0000_i1026"
              src="cid:part2.359AAF91.52AD3A26@gmail.com"
              alt="Beskrivelse:
C:\Users\lin\AppData\Roaming\Microsoft\signatures\284x82-3741133837051347070"
              class="" width="284" height="82" border="0"></span><o:p></o:p></p>
        <table class="MsoNormalTable" style="width:225.0pt" width="300"
          cellspacing="0" cellpadding="0" border="0">
          <tbody>
            <tr>
              <td style="padding:0cm 0cm 0cm 0cm">
                <p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Arial","sans-serif";color:red">T</span></b><o:p></o:p></p>
              </td>
              <td style="padding:0cm 0cm 0cm 0cm">
                <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">6313
                    6800</span><o:p></o:p></p>
              </td>
              <td style="padding:0cm 0cm 0cm 0cm">
                <p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Arial","sans-serif";color:red">@</span></b><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""> </span><o:p></o:p></p>
              </td>
              <td style="padding:0cm 0cm 0cm 0cm">
                <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""><a class="moz-txt-link-abbreviated" href="mailto:lin@lifa.dk">lin@lifa.dk</a></span><o:p></o:p></p>
              </td>
            </tr>
            <tr>
              <td style="padding:0cm 0cm 0cm 0cm">
                <p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Arial","sans-serif";color:red">D</span></b><o:p></o:p></p>
              </td>
              <td style="padding:0cm 0cm 0cm 0cm">
                <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">6313
                    6849</span><o:p></o:p></p>
              </td>
              <td style="padding:0cm 0cm 0cm 0cm">
                <p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Arial","sans-serif";color:red">W</span></b><o:p></o:p></p>
              </td>
              <td style="padding:0cm 0cm 0cm 0cm">
                <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""><a
                      href="http://www.lifa.dk" moz-do-not-send="true"><span
                        style="color:blue">www.lifa.dk</span></a></span><o:p></o:p></p>
              </td>
            </tr>
            <tr>
              <td style="padding:0cm 0cm 0cm 0cm">
                <p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Arial","sans-serif";color:red">M</span></b><o:p></o:p></p>
              </td>
              <td style="padding:0cm 0cm 0cm 0cm">
                <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">2492
                    4866</span><o:p></o:p></p>
              </td>
              <td style="padding:0cm 0cm 0cm 0cm">
                <p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Arial","sans-serif";color:red">CVR</span></b><o:p></o:p></p>
              </td>
              <td style="padding:0cm 0cm 0cm 0cm">
                <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">20937289</span><o:p></o:p></p>
              </td>
            </tr>
          </tbody>
        </table>
        <p class="MsoNormal"><br>
          <a href="https://www.linkedin.com/company/lifa-a-s/"
            moz-do-not-send="true"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif";color:blue;mso-fareast-language:DA;text-decoration:none"><img
                id="_x0000_i1025"
                src="cid:part4.1CE0608F.669687C8@gmail.com"
                alt="Beskrivelse:
C:\Users\lin\AppData\Roaming\Microsoft\signatures\21x21-3019966288736195652"
                class="" width="21" height="21" border="0"></span></a><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""><br>
            Følg os på LinkedIn og læs de seneste nyheder fra LIFA A/S </span><o:p></o:p></p>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
QGIS-Developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a></pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Med venlig hilsen / Kind regards

Bo Victor Thomsen
</pre>
  </body>
</html>