Getting plain text from Plasma::TextEdit

HB mszubart at gmail.com
Tue Jul 21 18:11:48 CEST 2009


Richard, thank you very much.

'nativeWidget'... That is so barefacedly obvious... My perceptivity is poor. :|


Thank you again.
I'm sorry for wasting your time.

---
Mateusz Szubart

> KTextEdit has a toPlainText method:
>
> $ rbqtapi -rkorundum4 -p KDE::TextEdit |grep -i plain
> void QTextEdit::insertPlainText(const QString&)
> void QTextEdit::setPlainText(const QString&)
> QString QTextEdit::toPlainText() const
> enum QFrame::Plain
>
> And it is the underlying nativeWidget for Plasma::TextEdit. So you can
> get at the plain text like this:
>
> require 'plasma_applet'
>
> module TestTextEdit
>   class Main < PlasmaScripting::Applet
>     slots :showText
>
>     def initialize(parent, args = nil)
>       super
>     end
>
>     def init
>       @text_edit = Plasma::TextEdit.new(self)
>       connect(@text_edit, SIGNAL(:textChanged), self, SLOT(:showText))
>     end
>
>     def showText
>       puts @text_edit.nativeWidget.toPlainText
>     end
>   end
> end
>
> -- Richard
>   



More information about the Plasma-devel mailing list