Permalink
Browse files

qt label rendering project ready

  • Loading branch information...
1 parent 2351f7f commit d75660a5021ca88832aa9e5d07c0ea48708727dd @Helbrass committed Jun 21, 2011
Showing with 92 additions and 0 deletions.
  1. BIN qtlabel-opensuse-x64-bin
  2. +11 −0 qtlabel/main.cxx
  3. +47 −0 qtlabel/mainwindow.cxx
  4. +18 −0 qtlabel/mainwindow.h
  5. +16 −0 qtlabel/qtlabel.pro
View
Binary file not shown.
View
@@ -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
@@ -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
@@ -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
@@ -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

0 comments on commit d75660a

Please sign in to comment.