how to make background image not overlapped in other frames?
Moved
Unsolved
Qt for Python
-
0
im making an ui using qtdesigner. im put one background image and put another frame on it expecting the frame to be transparent but it rather has the same background image as the other frame. since stackoverflow imagelink doesnt work im leaving link here. image (https://i.imgur.com/4AmqsM2.png). i want the frame in the red square to be transparent. so how do i do that?
# -*- coding: utf-8 -*- ################################################################################ ## Form generated from reading UI file 'testVQBnYA.ui' ## ## Created by: Qt User Interface Compiler version 5.15.2 ## ## WARNING! All changes made in this file will be lost when recompiling UI file! ################################################################################ from PySide2.QtCore import * from PySide2.QtGui import * from PySide2.QtWidgets import * import df_rc class Ui_MainWindow(object): def setupUi(self, MainWindow): if not MainWindow.objectName(): MainWindow.setObjectName(u"MainWindow") MainWindow.resize(607, 534) MainWindow.setStyleSheet(u"") self.centralwidget = QWidget(MainWindow) self.centralwidget.setObjectName(u"centralwidget") self.centralwidget.setStyleSheet(u"\n" "background-image: url(:/newPrefix/\ubc30\uacbd.jpg); \n" "background-repeat: no-repeat;\n" "") self.widget_1 = QWidget(self.centralwidget) self.widget_1.setObjectName(u"widget_1") self.widget_1.setGeometry(QRect(120, 90, 181, 231)) self.widget_1.setStyleSheet(u"background-color: rgb(255, 255, 255);") MainWindow.setCentralWidget(self.centralwidget) self.retranslateUi(MainWindow) QMetaObject.connectSlotsByName(MainWindow) # setupUi def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None)) # retranslateUi
-
Don't know qtdesigner, but this may give you a clue:
self.setWindowFlag(Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground, True)
This is how I make my widget's background transparent in PySide6.