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. Transparent Widgets not working
Forum Updated to NodeBB v4.3 + New Features

Transparent Widgets not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 2.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.
  • GofferG Offline
    GofferG Offline
    Goffer
    wrote on last edited by
    #1

    Hello community,

    I can't get my widgets to be transparent, always end up with a black or fading to black background
    I'm on Gnome 2.28.2, I'm pretty sure it works on Windows though.

    from PySide import QtGui, QtCore
    
    widget = QtGui.QWidget()
    widget.setAttribute(QtCore.Qt.WA_TranslucentBackground)
    widget.show()
    

    Any solution for that ?

    Thx

    mrjjM 1 Reply Last reply
    0
    • GofferG Goffer

      Hello community,

      I can't get my widgets to be transparent, always end up with a black or fading to black background
      I'm on Gnome 2.28.2, I'm pretty sure it works on Windows though.

      from PySide import QtGui, QtCore
      
      widget = QtGui.QWidget()
      widget.setAttribute(QtCore.Qt.WA_TranslucentBackground)
      widget.show()
      

      Any solution for that ?

      Thx

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Goffer
      Hi
      Can you try with
      widget.setAttribute(Qt.WA_NoSystemBackground, True) also ?

      I assume you mean fully transparent and not faded color/semi. ?

      1 Reply Last reply
      0
      • GofferG Offline
        GofferG Offline
        Goffer
        wrote on last edited by Goffer
        #3

        Well, for the example sake we're trying fully transparent just to demonstrate that transparency doesn't work on some platforms.
        But my goal is to have a semi-transparent window (that requires custom painting) that's why I said fading to black since opacity is replaced by black.

        Even with the extra line it's still black, I've tested on Windows and it's black too ...

        But if I do :

        test_widget.setWindowOpacity(0.5)
        

        it works on Windows but not on Gnome ... but that's not what I want anyway (This will affect the entire window not only the background)

        I need a way to set opacity that is going to work on all platforms or at least the main ones.

        1 Reply Last reply
        0
        • GofferG Offline
          GofferG Offline
          Goffer
          wrote on last edited by
          #4

          I have an other piece of code that represent exactly what I'm trying to do.

          form PySide import QtGui, QtCore
          
          class RoundWindow(QtGui.QWidget):
              def __init__(self):
                  super(RoundWindow, self).__init__()
                  self.initUI()
          
              def initUI(self):
                  self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
                  self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
          
              def sizeHint(self):
                  return QtCore.QSize(300,300)
          
              def paintEvent(self, event):
                  qp = QtGui.QPainter()
                  qp.begin(self)
                  qp.setRenderHint(QtGui.QPainter.Antialiasing);
                  qp.setPen(QtCore.Qt.NoPen);
                  qp.setBrush(QtGui.QColor(255, 0, 0, 127));
                  qp.drawEllipse(0, 0, 300, 300);
                  qp.end()
          
          
          rw = RoundWindow()
          rw.show()
          
          

          This works perfectly on Windows, but no luck on Gnome, I have a black square with my red circle

          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