PyQt5 创建无边框窗口
#! /usr/bin/env python
# -*- coding:utf-8 -*-
import sys
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtCore import Qt
class NoBorderWindow(QWidget):
def __init__(self):
super().__init__()
self.window_UI()
self.qss()
def window_UI(self):
self.resize(600, 200)
self.setWindowFlags(Qt.FramelessWindowHint)
def qss(self):
self.qssfile = "./qss/noborder.qss"
self.style = CommonStyleSheet.loadqss(self.qssfile)
self.setStyleSheet(self.style)
class CommonStyleSheet:
def __init__(self):
pass
@staticmethod
def loadqss(style):
with open (style, "r", encoding="utf-8") as f:
return f.read()
if __name__ == "__main__":
app = QApplication(sys.argv)
win = NoBorderWindow()
win.show()
sys.exit(app.exec_())
Qss文件
QWidget{
background-color:greenyellow;
}