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

List:       pykde
Subject:    [PyQt] How do I can get a Attribute::Ptr?
From:       J._Pablo_Martín_Cobos <goinnn () gmail ! com>
Date:       2012-02-29 16:46:24
Message-ID: CALNyWLG4Aj3+2xCkEmv8+4AyMsiC4pX5BOBJCKDyP9AcHsw3Bg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,

I am developing a plugins to Kate[1] with PyKDE .

In a plugin I want to highlight one piece of a text. Something like this[2]:


    KTextEditor::Attribute::Ptr attr(new KTextEditor::Attribute());
    attr->setBackground(Qt::yellow);
    ...
    KTextEditor::MovingRange* mr = miface->newMovingRange(matches.first());
    mr->setAttribute(attr);

But in python this does not work:

    attr = KTextEditor.Attribute(KTextEditor.Attribute())
    attr.setBackground(Qt.yellow)

    si = doc.smartInterface()
    sstart = si.newSmartCursor(start.line()+1, start.column()+1)
    send = si.newSmartCursor(end.line()-2, end.column()-2)
    mr = si.newSmartRange(sstart, send)
    mr.setAttribute(attr)

    *** TypeError: argument 1 of SmartRange.setAttribute() has an invalid
type

I think that the problem is that I am passing a param of the
"KTextEditor::Attribute" class, and I have to pass a param of the
"KTextEditor::Attribute::Ptr" class


  [1]: https://github.com/goinnn/Kate-plugins
  [2]:
https://projects.kde.org/projects/kde/kde-baseapps/kate/repository/revisions/master/entry/part/plugins/hlselection/hlselectionplugin.cpp#L144


Best Regards,

--

Pablo Martín


[Attachment #5 (text/html)]

Hi,<div><br></div><div><div>I am developing a plugins to Kate[1] with PyKDE \
.</div><div><br></div><div>In a plugin I want to highlight one piece of a text. \
Something like this[2]:</div><div><br></div><div><br></div><div>    \
KTextEditor::Attribute::Ptr attr(new KTextEditor::Attribute());</div> <div>    \
attr-&gt;setBackground(Qt::yellow);</div><div>    ...</div><div>    \
KTextEditor::MovingRange* mr = miface-&gt;newMovingRange(matches.first());</div><div> \
mr-&gt;setAttribute(attr);</div><div><br></div><div>But in python this does not \
work:</div> <div><br></div><div>    attr = \
KTextEditor.Attribute(KTextEditor.Attribute())</div><div>    \
attr.setBackground(Qt.yellow)</div><div><br></div><div>    si = \
doc.smartInterface()</div><div>    sstart = si.newSmartCursor(start.line()+1, \
start.column()+1)</div> <div>    send = si.newSmartCursor(end.line()-2, \
end.column()-2)</div><div>    mr = si.newSmartRange(sstart, send)</div><div>    \
mr.setAttribute(attr)</div><div><br></div><div>    *** TypeError: argument 1 of \
SmartRange.setAttribute() has an invalid type</div> <div><br></div><div>I think that \
the problem is that I am passing a param of the &quot;KTextEditor::Attribute&quot; \
class, and I have to pass a param of the &quot;KTextEditor::Attribute::Ptr&quot; \
class</div><div><br></div> <div><br></div><div>  [1]: <a \
href="https://github.com/goinnn/Kate-plugins">https://github.com/goinnn/Kate-plugins</a></div><div> \
[2]: <a href="https://projects.kde.org/projects/kde/kde-baseapps/kate/repository/revis \
ions/master/entry/part/plugins/hlselection/hlselectionplugin.cpp#L144">https://project \
s.kde.org/projects/kde/kde-baseapps/kate/repository/revisions/master/entry/part/plugins/hlselection/hlselectionplugin.cpp#L144</a></div>
 </div><div><br></div><div>Best \
Regards,</div><div><br></div><div>--</div><div><br></div><div>Pablo Martín</div>



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

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

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