<div dir="ltr">I&#39;v spend all morning working on Rocs trying to implement a multi-document panel interface, <br>almost everything is good, but this little piece of code here is somewhat broken, <br>my head hurts, anybody can show some light on this, pretty please, with sugar on top?<br>
<pre class="code" id="codemain"><span class="keyword">void</span> FileArea::createNewScript(){<br>   KTextEditor::Editor *e = _mainWindow-&gt;editor();<br>   KTextEditor::Document* d = e -&gt; createDocument(0);<br>   d-&gt;setMode(<span class="literal">&quot;JavaScript&quot;</span>);<br>
   addScript(d-&gt;documentName(), d);<br>}<br>&nbsp;<br><span class="keyword">void</span> FileArea::addScript(<span class="keyword">const</span> QString&amp; name, KTextEditor::Document* data){<br>   QTreeWidgetItem *scriptItem = <span class="keyword">new</span> QTreeWidgetItem(_scriptFolder);<br>
   scriptItem-&gt;setIcon(0, KIcon(<span class="literal">&quot;file-new&quot;</span>));<br>   scriptItem-&gt;setText(0, name);<br>   scriptItem-&gt;setData(0, ScriptRole, data);<br>  _mainWindow-&gt;changeActive(scriptItem);<br>
}<br>&nbsp;<br><span class="keyword">void</span> MainWindow::changeActiveScript(QTreeWidgetItem *item){<br>  KTextEditor::Document *d = item-&gt;data(0, FileArea::ScriptRole));<br>  _scriptingArea-&gt;setDocument( d );<br>  guiFactory()-&gt;addClient(_scriptingArea-&gt;view());<br>
}<br>&nbsp;<br>ERROR:<br>&nbsp;<br>cannot convert <span class="literal">&#39;QVariant&#39;</span> to <span class="literal">&#39;KTextEditor::Document*&#39;</span> in initialization<br>the line   KTextEditor::Document *d = item-&gt;data(0, FileArea::ScriptRole)); gives me a QVariant, <br>
I<span class="literal">&#39;v tried to qobject_cast&lt;KTextEditor*&gt;(item-&gt;data(0, FileArea::ScriptRole)); but also without luck.<br></span>&nbsp;<br>Anybody can give-me some light? i<span class="literal">&#39;m stuck here almost all morning.</span></pre>
-- <br>Um Computador sem Windows é como um Navio sem dançarinas de Can-Can<br>
</div>