Qt.FramelessWindowHint and WA_TranslucentBackground not working
-
hi,
i create window with Qt Designer.
after i convert the GUI file to PY file i try to add 2 functions:- FramelessWindowHint.
- WA_TranslucentBackground.
unfortunately the tool does not recognize these functions.
please attached my code:
from PyQt5 import QtCore, QtGui, QtWidgets import sys, res class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") Form.resize(625, 565) Form.setWindowFlag(QtCore.Qt.FramelessWindowHint) Form.setAttribute(QtCore.Qt.WA_TranslucentBackground) self.widget = QtWidgets.QWidget(Form) self.widget.setGeometry(QtCore.QRect(30, 30, 550, 500)) self.widget.setStyleSheet("QPushButton#pushButton{\n" " background-color: qlineargradient(spread:pad, x1:0, y1:0.505682, x2:1, y2:0.477, stop:0 rgba(11, 131, 120, 219), stop:1 rgba(85, 98, 112, 226));\n" " color: rgba(255, 255, 255, 210);\n" " border-radius: 5px;\n" "}\n" "\n" "QPushButton#pushButton:hover{\n" " background-color: qlineargradient(spread:pad, x1:0, y1:0.505682, x2:1, y2:0.477, stop:0 rgba(150, 123, 111, 219), stop:1 rgba(85, 81, 84, 226)); \n" "}\n" "\n" "QPushButton#pushButton:pressed{\n" " padding-left:5px;\n" " padding-top:5px;\n" " background-color:rgba(150, 123, 111,255);\n" "}\n" "\n" "\n" "\n" "") self.widget.setObjectName("widget") self.label = QtWidgets.QLabel(self.widget) self.label.setGeometry(QtCore.QRect(40, 30, 280, 430)) self.label.setStyleSheet("border-image: url(C:/python_projects/MIT_project/Pics/best-Mac-wallpapers-apps.jpg);\n" "border-top-left-radius: 50px;\n" "\n" "") self.label.setText("") self.label.setObjectName("label") self.label_2 = QtWidgets.QLabel(self.widget) self.label_2.setGeometry(QtCore.QRect(270, 30, 240, 430)) self.label_2.setStyleSheet("border-bottom-right-radius: 50px;\n" "background-color: rgba(255, 255, 255, 255);") self.label_2.setText("") self.label_2.setObjectName("label_2") self.label_3 = QtWidgets.QLabel(self.widget) self.label_3.setGeometry(QtCore.QRect(340, 80, 100, 40)) font = QtGui.QFont() font.setPointSize(20) font.setBold(True) font.setWeight(75) self.label_3.setFont(font) self.label_3.setStyleSheet("color: rgba(0, 0, 0, 200);") self.label_3.setObjectName("label_3") self.lineEdit = QtWidgets.QLineEdit(self.widget) self.lineEdit.setGeometry(QtCore.QRect(295, 150, 190, 40)) font = QtGui.QFont() font.setPointSize(10) self.lineEdit.setFont(font) self.lineEdit.setStyleSheet("background-color: rgba(0, 0, 0, 0);\n" "border:nane;\n" "border-bottom:2px solid rgba(46,82,101,200);\n" "color:rgba(0,0,0,240);\n" "padding-bottom:7px;") self.lineEdit.setObjectName("lineEdit") self.lineEdit_2 = QtWidgets.QLineEdit(self.widget) self.lineEdit_2.setGeometry(QtCore.QRect(295, 215, 190, 40)) font = QtGui.QFont() font.setPointSize(10) self.lineEdit_2.setFont(font) self.lineEdit_2.setStyleSheet("background-color: rgba(0, 0, 0, 0);\n" "border:nane;\n" "border-bottom:2px solid rgba(46,82,101,200);\n" "color:rgba(0,0,0,240);\n" "padding-bottom:7px;") self.lineEdit_2.setEchoMode(QtWidgets.QLineEdit.Password) self.lineEdit_2.setObjectName("lineEdit_2") self.pushButton = QtWidgets.QPushButton(self.widget) self.pushButton.setGeometry(QtCore.QRect(295, 295, 190, 40)) font = QtGui.QFont() font.setPointSize(11) font.setBold(True) font.setWeight(75) self.pushButton.setFont(font) self.pushButton.setStyleSheet("") self.pushButton.setObjectName("pushButton") self.label_4 = QtWidgets.QLabel(self.widget) self.label_4.setGeometry(QtCore.QRect(300, 340, 181, 31)) self.label_4.setStyleSheet("color:rgba(0, 0, 0, 210);") self.label_4.setObjectName("label_4") self.label_5 = QtWidgets.QLabel(self.widget) self.label_5.setGeometry(QtCore.QRect(40, 90, 230, 130)) self.label_5.setStyleSheet("background-color:rgba(0, 0, 0, 75);") self.label_5.setText("") self.label_5.setObjectName("label_5") self.label_6 = QtWidgets.QLabel(self.widget) self.label_6.setGeometry(QtCore.QRect(50, 80, 180, 40)) font = QtGui.QFont() font.setPointSize(22) font.setBold(True) font.setWeight(75) self.label_6.setFont(font) self.label_6.setStyleSheet("color:rgba(255, 255, 255, 255);") self.label_6.setObjectName("label_6") self.label_7 = QtWidgets.QLabel(self.widget) self.label_7.setGeometry(QtCore.QRect(50, 145, 220, 50)) font = QtGui.QFont() font.setPointSize(10) font.setBold(True) font.setWeight(75) self.label_7.setFont(font) self.label_7.setStyleSheet("color:rgba(255, 255, 255, 255);") self.label_7.setObjectName("label_7") self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): _translate = QtCore.QCoreApplication.translate Form.setWindowTitle(_translate("Form", "Form")) self.label_3.setText(_translate("Form", "Log In")) self.lineEdit.setPlaceholderText(_translate("Form", "User Name")) self.lineEdit_2.setPlaceholderText(_translate("Form", "Password")) self.pushButton.setText(_translate("Form", "L o g I n")) self.label_4.setText(_translate("Form", "Forgot your User Name or Password?")) self.label_6.setText(_translate("Form", "MIT APP")) self.label_7.setText(_translate("Form", "Hi, \n" "Welcome to FPGA team \n" "register tool.")) if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) Form = QtWidgets.QWidget() ui = Ui_Form() ui.setupUi(Form) Form.show() sys.exit(app.exec_())
what i miss?
thanks.
-
Hi and welcome to devnet,
What exact issue are you getting ?