Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7052805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:25:40+00:00 2026-05-28T03:25:40+00:00

I have a PyQt4.9 window where I would like to toggle the translucency on

  • 0

I have a PyQt4.9 window where I would like to toggle the translucency on or off. The reason being is that it sometimes shows a full size phonon video control which doesn’t work when the WA_TranslucentBackground attribute is set. (Due to a Qt bug https://bugreports.qt.io/browse/QTBUG-8119)

The problem I have is, after I turn WA_TranslucentBackground attribute back to false, after it has been true, the Window will no longer redraw, so it remains stuck showing the same thing from that point on. Interestingly, click events still respond.

Some example code follows. Click the increment button, and it will update the button text. Click the toggle button and then click the increment button again, and updates no longer show. Clicking the exit button closes the window, showing the events are still responding.

If anyone has any solutions, workarounds or fixes I’d appreciate them. Thanks.

import sys

from PyQt4.QtCore import *
from PyQt4.QtGui import *

class Settings(QWidget):

    def __init__(self, desktop):    
        QWidget.__init__(self)
        self.setAttribute(Qt.WA_TranslucentBackground, True)
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.istransparent = True
        self.count = 0
        self.setWindowTitle("Transparent")
        self.resize(300, 150)
        self.incr_button = QPushButton("Increment")
        toggle_button = QPushButton("Toggle Transparency")
        exit_button = QPushButton("Exit")
        grid = QGridLayout()
        grid.addWidget(self.incr_button, 0, 0)
        grid.addWidget(toggle_button, 1, 0)
        grid.addWidget(exit_button, 2, 0)
        self.setLayout(grid)        
        self.connect(toggle_button, SIGNAL("clicked()"), self.toggle)
        self.connect(self.incr_button, SIGNAL("clicked()"), self.increment)
        self.connect(exit_button, SIGNAL("clicked()"), self.close)

    def increment(self):
        self.count = self.count + 1
        self.incr_button.setText("Increment (%i)" % self.count)

    def toggle(self):
        self.istransparent = not self.istransparent
        self.setAttribute(Qt.WA_TranslucentBackground, self.istransparent)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    s = Settings(app.desktop())
    s.show()
    sys.exit(app.exec_())
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:25:41+00:00Added an answer on May 28, 2026 at 3:25 am

    Try to replace self.setAttribute(Qt.WA_TranslucentBackground, ...) calls in __init__ and toggle with following method.

    def set_transparency(self, enabled):
        if enabled:
            self.setAutoFillBackground(False)
        else:
            self.setAttribute(Qt.WA_NoSystemBackground, False)
    
        self.setAttribute(Qt.WA_TranslucentBackground, enabled)
        self.repaint()
    

    Tested on PyQt-Py2.7-x86-gpl-4.9-1 (Windows 7)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have quite a 'heavy' python program that I would like compiled to an
I have an application that writes its own stylesheet, based off user input. It
I have a PyQt program used to visualize some python objects. I would like
I have a PyQt4 program that I froze using cx_freeze. The problem I am
Python 2.7, PyQt4.8.5 I want to have a main app window and then a
I have a TextEdit widget in PyQt that I use to print out a
I basically have a QMainWindow, and a Dialog window whose constructor is shown below;
I have a Python program uses Qt (PyQt4 in fact) and when I launch
I have a progress which I mintor with a QProgessDialog in PyQt4. Basicly, I
I have another problem with PyQT, this time I have an example that will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.