<div dir="ltr">QGIS Layer List upgrade to V3 C++ plugin - Geographic Information Systems Stack Exchange
<noscript id="gmail-noscript-css"><style>body,.top-bar{margin-top:1.9em}</style></noscript>
<div class="gmail-container"><div id="gmail-content"><div class="gmail-inner-content gmail-clearfix"><div id="gmail-mainbar"><div class="gmail-question" id="gmail-question"><div class="gmail-post-layout"><div class="gmail-postcell gmail-post-layout--right"><div class="gmail-post-text"><p>I was upgrading a c++ plugin that I had used in the past and almost eliminated all the the usual compiler errors due to version changes according for the current version (3.6). The plugin used to collect current map canvas layers in a combo list box for selection. I am getting two errors that I can't figure out what to do with. This code compiled without problem pre-2.0.</p><p>The first happens to be about QGSMapLayer that can't be instantiated because it is turned as an abstract class and I am getting an error [Severity Code Description Project File Line Source Suppression State Error C2259 'QgsMapLayer': cannot instantiate abstract class tarjan_sccplugin C:\OSGeo4W64\apps\Qt5\include\QtCore\qlist.h 214 Build ]</p><p>This is portion of the code generating the error. Where cmbNetSourceLayer is a combo-box .</p><p>void tarjan_sccGui::populateLayers( QString const& url ) { cmbNetSourceLayer->clear();</p><p>QString layerName; QString layerType;</p><pre class="gmail-lang-cpp gmail-prettyprint gmail-prettyprinted"><code><span class="gmail-com">// fill list of layers</span><span class="gmail-pln">
</span><span class="gmail-typ">QMap</span><span class="gmail-pun"><</span><span class="gmail-typ">QString</span><span class="gmail-pun">,</span><span class="gmail-pln"> </span><span class="gmail-typ">QgsMapLayer</span><span class="gmail-pun">*></span><span class="gmail-pln"> mapLayers </span><span class="gmail-pun">=</span><span class="gmail-pln"> </span><span class="gmail-typ">QgsProject</span><span class="gmail-pun">::</span><span class="gmail-pln">instance</span><span class="gmail-pun">()-></span><span class="gmail-pln">mapLayers</span><span class="gmail-pun">();</span><span class="gmail-pln">
</span><span class="gmail-typ">QMap</span><span class="gmail-pun"><</span><span class="gmail-typ">QString</span><span class="gmail-pun">,</span><span class="gmail-pln"> </span><span class="gmail-typ">QgsMapLayer</span><span class="gmail-pun">*>::</span><span class="gmail-typ">iterator</span><span class="gmail-pln"> layer_it </span><span class="gmail-pun">=</span><span class="gmail-pln"> mapLayers</span><span class="gmail-pun">.</span><span class="gmail-pln">begin</span><span class="gmail-pun">();</span><span class="gmail-pln">
</span><span class="gmail-kwd">for</span><span class="gmail-pln"> </span><span class="gmail-pun">(;</span><span class="gmail-pln"> layer_it </span><span class="gmail-pun">!=</span><span class="gmail-pln"> mapLayers</span><span class="gmail-pun">.</span><span class="gmail-pln">end</span><span class="gmail-pun">();</span><span class="gmail-pln"> </span><span class="gmail-pun">++</span><span class="gmail-pln">layer_it</span><span class="gmail-pun">)</span><span class="gmail-pln">
</span><span class="gmail-pun">{</span><span class="gmail-pln">
</span><span class="gmail-typ">QgsVectorLayer</span><span class="gmail-pun">*</span><span class="gmail-pln"> vl </span><span class="gmail-pun">=</span><span class="gmail-pln"> </span><span class="gmail-kwd">dynamic_cast</span><span class="gmail-pun"><</span><span class="gmail-typ">QgsVectorLayer</span><span class="gmail-pun">*>(</span><span class="gmail-pln">layer_it</span><span class="gmail-pun">.</span><span class="gmail-pln">value</span><span class="gmail-pun">());</span><span class="gmail-pln">
</span><span class="gmail-kwd">if</span><span class="gmail-pln"> </span><span class="gmail-pun">(!</span><span class="gmail-pln">vl</span><span class="gmail-pun">)</span><span class="gmail-pln">
</span><span class="gmail-kwd">continue</span><span class="gmail-pun">;</span><span class="gmail-pln">
</span><span class="gmail-kwd">else</span><span class="gmail-pln">
cmbNetSourceLayer</span><span class="gmail-pun">-></span><span class="gmail-pln">addItem</span><span class="gmail-pun">(</span><span class="gmail-pln">vl</span><span class="gmail-pun">-></span><span class="gmail-pln">name</span><span class="gmail-pun">()</span><span class="gmail-pln"> </span><span class="gmail-pun">);</span><span class="gmail-pln">
</span><span class="gmail-pun">}</span></code></pre><p>The second error appears to be in explicit declaration for the plugin. Something has changed in how the plugins are initiated. [Severity Code Description Project File Line Source Suppression State Error (active) invalid explicit instantiation declaration tarjan_sccplugin d:\GIS\v3\Quantum-GIS\src\core\qgsoptionalexpression.h 82 IntelliSense ]</p><p>No idea what must be done to overcome this error. The cited module appears to be an optional data module.</p><p><br></p><p>Any help is appreciated.</p></div></div></div></div></div></div></div></div></div>