def __init__(self, parent=None): super(FramelessWindow, self).__init__(parent) self.__rect = QApplication.instance().desktop().availableGeometry(self) self.__titlebarHeight = 45 self.__borderWidth = 3 self.hwnd = None if QtWin.isCompositionEnabled(): QtWin.extendFrameIntoClientArea(self, -1, -1, -1, -1) else: QtWin.resetExtendedFrame(self) QMetaObject.connectSlotsByName(self)
def __init__(self): super().__init__() # get the available resolutions without taskbar self._rect = QApplication.instance().desktop().availableGeometry(self) self.resize(800, 600) self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint | Qt.WindowSystemMenuHint | Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint | Qt.WindowCloseButtonHint) # Create a thin frame style = win32gui.GetWindowLong(int(self.winId()), win32con.GWL_STYLE) win32gui.SetWindowLong(int(self.winId()), win32con.GWL_STYLE, style | win32con.WS_THICKFRAME) if QtWin.isCompositionEnabled(): # Aero Shadow QtWin.extendFrameIntoClientArea(self, -1, -1, -1, -1) else: QtWin.resetExtendedFrame(self) # Window Widgets self._layout = QVBoxLayout() self._layout.setContentsMargins(0, 0, 0, 0) self._layout.setSpacing(0) self.controlWidget = AnotherWidget() self.controlWidget.setObjectName("controlWidget") # main widget is here self.mainWidget = QWidget() self.mainWidgetLayout = QVBoxLayout() self.mainWidgetLayout.setContentsMargins(0, 0, 0, 0) self.mainWidget.setLayout(self.mainWidgetLayout) self.mainWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) # set background color self.mainWidget.setAutoFillBackground(True) p = self.mainWidget.palette() p.setColor(self.mainWidget.backgroundRole(), QColor("#272727")) self.mainWidget.setPalette(p) self._layout.addWidget(self.controlWidget) self._layout.addWidget(self.mainWidget) self.setLayout(self._layout) self.show()
def mainwindow_area_config(self, root): # 主屏幕的可用大小(去掉任务栏) self._rect = QApplication.instance().desktop().availableGeometry(root) # self.resize(800, 600) root.setWindowFlags(Qt.Window | Qt.FramelessWindowHint | Qt.WindowSystemMenuHint | Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint | Qt.WindowCloseButtonHint) # 增加薄边框 style = win32gui.GetWindowLong(int(root.winId()), win32con.GWL_STYLE) win32gui.SetWindowLong(int(root.winId()), win32con.GWL_STYLE, style | win32con.WS_SIZEBOX) if QtWin.isCompositionEnabled(): # 加上 Aero 边框阴影 QtWin.extendFrameIntoClientArea(root, 0, 0, 0, 0) else: QtWin.resetExtendedFrame(root)
def __init__(self, *args, **kwargs): super(Window, self).__init__(*args, **kwargs) # 主屏幕的可用大小(去掉任务栏) self._rect = QApplication.instance().desktop().availableGeometry(self) self.resize(800, 600) self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint | Qt.WindowSystemMenuHint | Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint | Qt.WindowCloseButtonHint) # 增加薄边框 style = win32gui.GetWindowLong(int(self.winId()), win32con.GWL_STYLE) win32gui.SetWindowLong(int(self.winId()), win32con.GWL_STYLE, style | win32con.WS_THICKFRAME) if QtWin.isCompositionEnabled(): # 加上 Aero 边框阴影 QtWin.extendFrameIntoClientArea(self, -1, -1, -1, -1) else: QtWin.resetExtendedFrame(self)