Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
78 additions
and
79 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,77 @@ | ||
#include <QtCore/QString> | ||
#include <QtCore/QStringList> | ||
#include <QtCore/QTextStream> | ||
#include <QtGui/QApplication> | ||
#include "mainwindow.h" | ||
#include <QtGui/QFont> | ||
#include <QtGui/QFontDatabase> | ||
#include <QtGui/QLabel> | ||
#include <QtGui/QMainWindow> | ||
#include <QtGui/QVBoxLayout> | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
int main(int argc, char *argv[]) { | ||
QApplication a(argc, argv); | ||
MainWindow w; | ||
w.show(); | ||
|
||
QString file("/usr/share/fonts/truetype/DejaVuSansMono.ttf"); | ||
int size = 10; | ||
|
||
QTextStream out(stdout); | ||
out << "Qt font viewer demo.\n" | ||
<< "By default shown font is " | ||
<< file | ||
<< " size " | ||
<< size | ||
<< ".\n" | ||
<< "usage: --file <path to TTF file to read font from> --size <font size>\n"; | ||
out.flush(); | ||
|
||
QStringList args = a.arguments(); | ||
// starting i is 1 because app name at position 0 | ||
for (int i = 1; i < args.size(); i++) { | ||
if (args.at(i) == "--file") { | ||
i++; | ||
file = args.at(i); | ||
continue; | ||
} | ||
if (args.at(i) == "--size") { | ||
i++; | ||
size = args.at(i).toInt(); | ||
continue; | ||
} | ||
} | ||
|
||
int fontId = QFontDatabase::addApplicationFont(file); | ||
QString family = QFontDatabase::applicationFontFamilies(fontId).at(0); | ||
|
||
QFont font(family, size); | ||
QLabel* label = new QLabel("The quick brown fox jumps over the lazy dog"); | ||
QPalette p = label->palette(); | ||
p.setColor(QPalette::WindowText, Qt::black); | ||
label->setPalette(p); | ||
label->setFont(font); | ||
label->setContentsMargins(0, 0, 0, 0); | ||
|
||
QVBoxLayout* layout = new QVBoxLayout(); | ||
layout->setContentsMargins(0, 0, 0, 0); | ||
layout->setMargin(0); | ||
layout->setSpacing(0); | ||
layout->addWidget(label, 0, Qt::AlignCenter); | ||
|
||
QWidget* centralWidget = new QWidget(); | ||
centralWidget->setContentsMargins(20, 20, 20, 20); | ||
centralWidget->setLayout(layout); | ||
centralWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); | ||
centralWidget->adjustSize(); | ||
centralWidget->updateGeometry(); | ||
|
||
QMainWindow* w = new QMainWindow(); | ||
p = w->palette(); | ||
p.setColor(QPalette::Window, Qt::white); | ||
w->setPalette(p); | ||
w->setWindowTitle("fontview qt"); | ||
w->setCentralWidget(centralWidget); | ||
w->move(0, 0); | ||
w->resize(centralWidget->size()); | ||
w->show(); | ||
|
||
return a.exec(); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
#------------------------------------------------- | ||
# | ||
# Project created by QtCreator 2011-06-21T13:38:03 | ||
# Project created by QtCreator 2011-06-26T11:12:27 | ||
# | ||
#------------------------------------------------- | ||
|
||
QT += core gui | ||
|
||
TARGET = qtlabel | ||
TARGET = qtfontview | ||
TEMPLATE = app | ||
|
||
|
||
SOURCES += main.cxx\ | ||
mainwindow.cxx | ||
SOURCES += main.cxx | ||
|
||
HEADERS += mainwindow.h | ||
HEADERS += |
Binary file not shown.
Binary file not shown.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/bin/sh | ||
thisdirname=$( readlink -f "$( dirname "$0" )" ) | ||
demo/qtdemo-opensuse-x64-bin | ||
demo/qtfontview-opensuse-x64-bin $* |