1

I have a question related to qtextedit. I have a GUI in which the Qtextedit widget gets populated once when i press a button (basically after running a process). Now i want to save the contents of the qtext edit widget to *.txt file.

I referred the docs but i did'nt get any particular method like gettext() of a qlineedit.

How to do this ? help me with this

enter image description here

ayaan
  • 715
  • 5
  • 18
  • 36
  • 1
    Which part of this are you having trouble with? Is it that you don't know how to get the text out of the widget, or how to save that into a file? – jonrsharpe Sep 08 '14 at 10:08
  • i have problem with both i want the contents to be saved into a text file, my gui looks like the one in the picture which i attached. – ayaan Sep 08 '14 at 10:12
  • Then this is probably two separate questions, both of which are trivially answered elsewhere: http://stackoverflow.com/q/2063633/3001761 and http://stackoverflow.com/q/5214578/3001761, for example. How the GUI looks isn't really relevant. – jonrsharpe Sep 08 '14 at 10:16

1 Answers1

7

Huummm ..., I document have it, isn't it ?

In QTextEdit have 2 method available for get text in frame;

QString QTextEdit.toHtml (self)

QString QTextEdit.toPlainText (self)

little example;

.
.
.
yourQTextEdit = QtGui.QTextEdit() 
.
.
.
with open('log.txt', 'w') as yourFile:
    yourFile.write(str(yourQTextEdit.toPlainText()))
Bandhit Suksiri
  • 3,390
  • 1
  • 18
  • 20