aboutsummaryrefslogtreecommitdiffstats
path: root/doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3textedit.cpp
blob: e8d5784a25fdc48274e6cfe482877295bf9ed72d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//! [0]
QFile file(fileName); // Read the text from a file
if (file.open(IO_ReadOnly)) {
    QTextStream stream(&file);
    textEdit->setText(stream.read());
}

QFile file(fileName); // Write the text to a file
if (file.open(IO_WriteOnly)) {
    QTextStream stream(&file);
    stream << textEdit->text();
    textEdit->setModified(false);
}
//! [0]


//! [1]
This is <font color=red>red</font> while <b>this</b> is <font color=blue>blue</font>.
<font color=green><font color=yellow>Yellow,</font> and <u>green</u>.
//! [1]


//! [2]
Q3TextEdit * log = new Q3TextEdit(this);
log->setTextFormat(Qt::LogText);
Q3StyleSheetItem * item = new Q3StyleSheetItem(log->styleSheet(), "mytag");
item->setColor("red");
item->setFontWeight(QFont::Bold);
item->setFontUnderline(true);
log->append("This is a <mytag>custom tag</mytag>!");
//! [2]