[PyQt] How do I can get a Attribute::Ptr?
J. Pablo Martín Cobos
goinnn at gmail.com
Wed Feb 29 16:46:24 GMT 2012
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120229/ef73f267/attachment.html>
More information about the PyQt
mailing list