Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Window QML type, color: "transparent"
Forum Updated to NodeBB v4.3 + New Features

Window QML type, color: "transparent"

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qml window
3 Posts 3 Posters 1.9k Views 2 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.
  • E Offline
    E Offline
    EStudley
    wrote on 15 May 2019, 22:23 last edited by
    #1

    I am using Qt 5.11.1 on Windows 10 with transparency mode setting for toolbars on.

    How can I set a Window QML object's color to transparent?

    The Window and Screen Qt Quick example shows the following code to create an empty QML Window with which an image can be placed for a splash screen, yet when I try the window is always black.

    Window {
        id: splash
        color: "transparent"
        title: "Splash Window"
        modality: Qt.ApplicationModal
        flags: Qt.SplashScreen
    }
    

    I can set opacity: 0 and get a transparent Window, but then all content inside the Window is hidden as well.

    Any ideas? Bug?

    Thanks.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Shrinidhi Upadhyaya
      wrote on 16 May 2019, 05:33 last edited by
      #2

      Hi @EStudley , you just need to set the flags property and the color to transparent.

       flags:  Qt.WA_TranslucentBackground | Qt.FramelessWindowHint
       color:  "#00000000"
      

      Here is the sample code:-

      Window {
      id: splash
      
      visible: true
      height: 500
      width: 500
      flags:  Qt.WA_TranslucentBackground | Qt.FramelessWindowHint
      color: "#00000000"
      
      Rectangle {
          height: 100
          width: 100
          color: "cyan"
        }
      }
      

      Shrinidhi Upadhyaya.
      Upvote the answer(s) that helped you to solve the issue.

      1 Reply Last reply
      2
      • F Offline
        F Offline
        fcarney
        wrote on 16 May 2019, 14:52 last edited by
        #3

        But Qt.WA_TranslucentBackground is a widget attribute:
        https://doc.qt.io/qt-5/qt.html#WidgetAttribute-enum
        not a flag for a window:
        https://doc.qt.io/qt-5/qt.html#WindowType-enum

        Is this how we set attributes for QML? Seems counter intuitive.

        C++ is a perfectly valid school of magic.

        1 Reply Last reply
        0

        1/3

        15 May 2019, 22:23

        • Login

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