Guest User

Untitled

a guest
Sep 15th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. main.cpp
  2. #include <QApplication>
  3. #include "qmlapplicationviewer.h"
  4.  
  5. #include <QGLWidget>
  6.  
  7. Q_DECL_EXPORT int main(int argc, char *argv[])
  8. {
  9.     QScopedPointer<QApplication> app(createApplication(argc, argv));
  10.  
  11.     QmlApplicationViewer viewer;
  12.     viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
  13.     viewer.setMainQmlFile(QLatin1String("qml/test/main.qml"));
  14.  
  15.     //viewer.setViewport(new QGLWidget());
  16.  
  17.     viewer.setAttribute(Qt::WA_TranslucentBackground);
  18.     viewer.setStyleSheet("background:transparent;");
  19.     viewer.setWindowFlags(Qt::FramelessWindowHint);
  20.     viewer.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform | QPainter::Antialiasing);
  21.  
  22.     viewer.showExpanded();
  23.  
  24.     return app->exec();
  25. }
  26.  
  27. main.qml
  28.  
  29. import QtQuick 1.1
  30. Rectangle {
  31.     width: 400
  32.     height: 400
  33.     color: "transparent"
  34.  
  35.     Rectangle {
  36.         width: 60
  37.         height: 60
  38.         anchors.centerIn: parent
  39.         color: "indigo"
  40.     }
  41.  
  42.     Rectangle {
  43.         width: 60
  44.         height: 60
  45.         color: "indigo"
  46.     }
  47.  
  48.     Rectangle {
  49.         width: 60
  50.         height: 60
  51.         anchors.right: parent.right
  52.         color: "indigo"
  53.     }
  54.  
  55.     Rectangle {
  56.         width: 60
  57.         height: 60
  58.         anchors { bottom: parent.bottom; }
  59.         color: "indigo"
  60.     }
  61.  
  62.     Rectangle {
  63.         width: 60
  64.         height: 60
  65.         anchors { bottom: parent.bottom; right: parent.right }
  66.         color: "indigo"
  67.     }
  68. }
Add Comment
Please, Sign In to add comment