[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-edu-devel
Subject:    [kde-edu]: Problem with QVariant on Rocs project (help request)
From:       "Tomaz Canabrava" <tumaix () gmail ! com>
Date:       2008-08-13 16:52:48
Message-ID: 7ebbb4b50808130952l1d857a62v4096b4419c12fc61 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I'v spend all morning working on Rocs trying to implement a multi-document
panel interface,
almost everything is good, but this little piece of code here is somewhat
broken,
my head hurts, anybody can show some light on this, pretty please, with
sugar on top?

void FileArea::createNewScript(){
   KTextEditor::Editor *e = _mainWindow->editor();
   KTextEditor::Document* d = e -> createDocument(0);
   d->setMode("JavaScript");
   addScript(d->documentName(), d);
}

void FileArea::addScript(const QString& name, KTextEditor::Document* data){
   QTreeWidgetItem *scriptItem = new QTreeWidgetItem(_scriptFolder);
   scriptItem->setIcon(0, KIcon("file-new"));
   scriptItem->setText(0, name);
   scriptItem->setData(0, ScriptRole, data);
  _mainWindow->changeActive(scriptItem);
}

void MainWindow::changeActiveScript(QTreeWidgetItem *item){
  KTextEditor::Document *d = item->data(0, FileArea::ScriptRole));
  _scriptingArea->setDocument( d );
  guiFactory()->addClient(_scriptingArea->view());
}

ERROR:

cannot convert 'QVariant' to 'KTextEditor::Document*' in initialization
the line   KTextEditor::Document *d = item->data(0,
FileArea::ScriptRole)); gives me a QVariant,
I'v tried to qobject_cast<KTextEditor*>(item->data(0,
FileArea::ScriptRole)); but also without luck.

Anybody can give-me some light? i'm stuck here almost all morning.

-- 
Um Computador sem Windows é como um Navio sem dançarinas de Can-Can

[Attachment #5 (text/html)]

<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>



_______________________________________________
kde-edu mailing list
kde-edu@mail.kde.org
https://mail.kde.org/mailman/listinfo/kde-edu


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic