Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]With Qt 5.2, is it possible to make a shaped window with .qml file?
Forum Updated to NodeBB v4.3 + New Features

[Solved]With Qt 5.2, is it possible to make a shaped window with .qml file?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 771 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cidhuang
    wrote on last edited by
    #1

    In Qt 4.8, QWidget with QDeclarativeView can make a shaped window, with the QWidget settings:

    @
    setWindowFlags(Qt::FramelessWindowHint);
    setStyleSheet("background :transparent;");
    setAttribute(Qt::WA_TranslucentBackground, true);
    @

    In Qt 5.2, QQuickView seems different from QDeclarativeView. I tried the same way as in Qt 4.8 but failed.

    I found Shaped Clock Example. Is it the only way for Qt 5.2 to make a shaped window?

    Thanks in advance.

    Cid

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cidhuang
      wrote on last edited by
      #2

      Under Win 7 64-bit, the following code can show shaped window defined in .qml file.

      However, the setMask() of QWindow seems not work, so even the transparent area receives mouse event.

      @
      #include <QtGui/QGuiApplication>
      #include "qtquick2applicationviewer.h"

      int main(int argc, char *argv[])
      {
      QGuiApplication app(argc, argv);

      QQuickView viewer;
      
      viewer.setFlags(Qt::FramelessWindowHint);
      viewer.setColor(QColor(0,0,0,0));
      viewer.setSource(QStringLiteral("qml/untitled2/main.qml"));
      
      viewer.show();
      
      return app.exec();
      

      }
      @

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved