Seite 1 von 1

kein qtextedit::text in qt4?

Verfasst: 18. März 2007 21:56
von Linuxguru
hallo..

ich möchte meinen text aus einem qtextedit einfach in eine datei speichern.
ist ja ansich kein problem.

als fehlermeldung erhalte ich allerdings, das text kein element von qtextedit ist. in der doku steht es aber drin.

QString QTextEdit::text () const
Returns all the text in the text edit as plain text.
See also setText().

hier meine save funktion

Code: Alles auswählen

void TestWidget::saveFile()
{
    QString text = textEdit->text();
    QFile f( fileName );
    if ( !f.open( QFile::WriteOnly ) ) {
	return;
    }

    QTextStream t( &f );
    t << text;
    f.close();
}
filename ist dabei ein QString.

danke im voraus!

Verfasst: 18. März 2007 22:05
von lepsai
Das ist richtig, QTextWidget hat keine text() funktion. Das, was du brauchst, ist toPlainText() oder toHtml()...

Verfasst: 18. März 2007 22:09
von Linuxguru
super...

das waren ja mal 100 punkte...

soweit ich mich erinnern kann, gab es das aber in qt3.

naja hauptsache es funzt.

Verfasst: 18. März 2007 22:21
von lepsai
hura...