Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

qt label rendering project ready

  • Loading branch information...
commit d75660a5021ca88832aa9e5d07c0ea48708727dd 1 parent 2351f7f
@Helbrass authored
View
BIN  qtlabel-opensuse-x64-bin
Binary file not shown
View
11 qtlabel/main.cxx
@@ -0,0 +1,11 @@
+#include <QtGui/QApplication>
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+
+ return a.exec();
+}
View
47 qtlabel/mainwindow.cxx
@@ -0,0 +1,47 @@
+#include "mainwindow.h"
+
+#include <QtGui/QVBoxLayout>
+
+MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
+ QPalette pltt = palette();
+ pltt.setColor(QPalette::Window, Qt::white);
+ setPalette(pltt);
+
+ QWidget* widget = new QWidget(this);
+ setCentralWidget(widget);
+
+ QVBoxLayout* layout = new QVBoxLayout(widget);
+ layout->setContentsMargins(12, 12, 12, 12);
+ layout->addWidget(createLabel("DejaVu Sans Mono", 10));
+ layout->addWidget(createLabel("Consolas", 10));
+ layout->addSpacing(20);
+ layout->addWidget(createLabel("DejaVu Sans Mono", 12));
+ layout->addWidget(createLabel("Consolas", 12));
+ layout->addSpacing(20);
+ layout->addWidget(createLabel("Monospace", 0));
+ layout->addWidget(createLabel("SansSerif", 0));
+ layout->addWidget(createLabel("Serif", 0));
+}
+
+MainWindow::~MainWindow() {
+}
+
+QLabel* MainWindow::createLabel(const QString &fontFamily, const int fontSize) {
+
+ QString text("The quick brown fox jumps over the lazy dog (");
+ text+=fontFamily;
+ if (fontSize > 0) {
+ text+=" ";
+ text+=QString::number(fontSize);
+ }
+ text+=")";
+
+ QLabel* label = new QLabel(text, this);
+ QFont fnt = label->font();
+ fnt.setFamily(fontFamily);
+ if (fontSize > 0) {
+ fnt.setPointSize(fontSize);
+ }
+ label->setFont(fnt);
+ return label;
+}
View
18 qtlabel/mainwindow.h
@@ -0,0 +1,18 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QtGui/QLabel>
+#include <QtGui/QMainWindow>
+
+class MainWindow : public QMainWindow {
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+private:
+ QLabel* createLabel(const QString& fontFamily, const int fontSize);
+};
+
+#endif // MAINWINDOW_H
View
16 qtlabel/qtlabel.pro
@@ -0,0 +1,16 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2011-06-21T13:38:03
+#
+#-------------------------------------------------
+
+QT += core gui
+
+TARGET = qtlabel
+TEMPLATE = app
+
+
+SOURCES += main.cxx\
+ mainwindow.cxx
+
+HEADERS += mainwindow.h
Please sign in to comment.
Something went wrong with that request. Please try again.