Last active
February 8, 2016 08:06
-
-
Save mitya57/0487148ae695223e899a to your computer and use it in GitHub Desktop.
A test example for https://codereview.qt-project.org/148563
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QtGui/QFont> | |
#include <QtWidgets/QApplication> | |
#include <QtWidgets/QTextEdit> | |
int main(int argc, char **argv) { | |
QApplication app(argc, argv); | |
QTextEdit edit; | |
edit.resize(640, 480); | |
edit.setHtml( | |
"<p style=\"background-color: white;\">" | |
" <span style=\"color: black\">black</span>" | |
" <span style=\"color: darkred;\">darkred</span>" | |
" <span style=\"color: darkgreen;\">darkgreen</span>" | |
" <span style=\"color: darkblue;\">darkblue</span>" | |
"</p>" | |
"<p style=\"background-color: black;\">" | |
" <span style=\"color: white\">white</span>" | |
" <span style=\"color: #ff9999;\">lightred</span>" | |
" <span style=\"color: lightgreen;\">lightgreen</span>" | |
" <span style=\"color: lightblue;\">lightblue</span>" | |
"</p>" | |
"<p style=\"color: black;\">" | |
" <span style=\"background-color: #ff9999;\">black on red</span>" | |
" <span style=\"background-color: lightgreen;\">black on green</span>" | |
" <span style=\"background-color: lightblue;\">black on blue</span>" | |
"</p>" | |
"<p style=\"color: white;\">" | |
" <span style=\"background-color: darkred;\">white on red</span>" | |
" <span style=\"background-color: darkgreen;\">white on green</span>" | |
" <span style=\"background-color: darkblue;\">white on blue</span>" | |
"</p>" | |
); | |
edit.setFont(QFont("monospace", 18)); | |
QFontMetrics metrics = edit.fontMetrics(); | |
edit.setCursorWidth(metrics.width(' ')); | |
edit.show(); | |
return app.exec(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment