Qt 5.10 Book Examples
chapter10
SyntaxHighlighter
main.cpp
Go to the documentation of this file.
1
// ======================================================================
2
// main.cpp
3
// ======================================================================
4
// This file is a part of the book
5
// "Qt 5.10 Professional programming with C++"
6
// http://qt-book.com
7
// ======================================================================
8
// Copyright (c) 2017 by Max Schlee
9
// ======================================================================
10
11
#include <QtWidgets>
12
#include "
SyntaxHighlighter.h
"
13
14
// ----------------------------------------------------------------------
15
int
main
(
int
argc,
char
** argv)
16
{
17
QApplication app(argc, argv);
18
QTextEdit txt;
19
20
QFont fnt(
"Lucida Console"
, 9, QFont::Normal);
21
txt.document()->setDefaultFont(fnt);
22
23
new
SyntaxHighlighter
(txt.document());
24
25
QPalette pal = txt.palette();
26
pal.setColor(QPalette::Base, Qt::darkBlue);
27
pal.setColor(QPalette::Text, Qt::yellow);
28
txt.setPalette(pal);
29
30
txt.show();
31
txt.resize(640, 480);
32
33
QFile file(
":/SyntaxHighlighter.cpp"
);
34
file.open(QFile::ReadOnly);
35
txt.setPlainText(QLatin1String(file.readAll()));
36
37
return
app.exec();
38
}
SyntaxHighlighter
Definition:
SyntaxHighlighter.h:18
main
int main(int argc, char **argv)
Definition:
main.cpp:15
SyntaxHighlighter.h
Generated by
1.8.14