<div dir="ltr">I'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->editor();<br> KTextEditor::Document* d = e -> createDocument(0);<br> d->setMode(<span class="literal">"JavaScript"</span>);<br>
addScript(d->documentName(), d);<br>}<br> <br><span class="keyword">void</span> FileArea::addScript(<span class="keyword">const</span> QString& name, KTextEditor::Document* data){<br> QTreeWidgetItem *scriptItem = <span class="keyword">new</span> QTreeWidgetItem(_scriptFolder);<br>
scriptItem->setIcon(0, KIcon(<span class="literal">"file-new"</span>));<br> scriptItem->setText(0, name);<br> scriptItem->setData(0, ScriptRole, data);<br> _mainWindow->changeActive(scriptItem);<br>
}<br> <br><span class="keyword">void</span> MainWindow::changeActiveScript(QTreeWidgetItem *item){<br> KTextEditor::Document *d = item->data(0, FileArea::ScriptRole));<br> _scriptingArea->setDocument( d );<br> guiFactory()->addClient(_scriptingArea->view());<br>
}<br> <br>ERROR:<br> <br>cannot convert <span class="literal">'QVariant'</span> to <span class="literal">'KTextEditor::Document*'</span> in initialization<br>the line KTextEditor::Document *d = item->data(0, FileArea::ScriptRole)); gives me a QVariant, <br>
I<span class="literal">'v tried to qobject_cast<KTextEditor*>(item->data(0, FileArea::ScriptRole)); but also without luck.<br></span> <br>Anybody can give-me some light? i<span class="literal">'m stuck here almost all morning.</span></pre>
-- <br>Um Computador sem Windows é como um Navio sem dançarinas de Can-Can<br>
</div>