zhiyiYo / PyQt-Fluent-Widgets

A fluent design widgets library based on C++ Qt/PyQt/PySide. Make Qt Great Again.
https://qfluentwidgets.com
GNU General Public License v3.0
5.49k stars 523 forks source link

[Bug]: 编写过程中,圆角边框没了 #903

Closed herui119110 closed 3 months ago

herui119110 commented 3 months ago

What happened?

不知道为什么就是圆角边框没了,学习阶段,仿照案例代码,但是得到的效果就是边框黑边正方形非常难看! image

Operation System

win10

Python Version

py 3.11.8

PyQt/PySide Version

5.15.7

PyQt/PySide-Fluent-Widgets Version

v.1.3.1

How to Reproduce?

该代码编译运行就会产生这个问题,纯新手,望帮助

Minimum code

import sys

from PyQt5.Qt import *

from mautohelper.app.window.main_window import MainWindow

QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    app.setAttribute(Qt.AA_DontCreateNativeWidgetSiblings)

    w = MainWindow()

    sys.exit(app.exec_())

------上面是启动类------
主窗体类
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication
from qfluentwidgets import MSFluentWindow, setThemeColor, setTheme, Theme, SplashScreen
from qfluentwidgets import FluentIcon as FIF
from mautohelper.app.widget.yuanshen_widget import YuanShenWidget

class MainWindow(MSFluentWindow):
    def __init__(self):
        super().__init__()
        self.initWindow()

        self.initInterface()
        self.initNavigation()

        # 检查更新
        # checkUpdate(self, flag=True)
        # checkAnnouncement(self)

    def initWindow(self):
        setThemeColor('#f18cb9', lazy=True)
        setTheme(Theme.AUTO, lazy=True)
        self.setMicaEffectEnabled(False)

        # 禁用最大化
        self.titleBar.maxBtn.setHidden(True)
        self.titleBar.maxBtn.setDisabled(True)
        self.titleBar.setDoubleClickEnabled(False)
        self.setResizeEnabled(False)
        self.setWindowFlags(Qt.WindowMinimizeButtonHint | Qt.WindowCloseButtonHint)

        self.resize(960, 640)
        self.setWindowIcon(QIcon('./assets/logo/March7th.ico'))
        self.setWindowTitle("March7th Assistant")

        # 创建启动画面
        self.splashScreen = SplashScreen(self.windowIcon(), self)
        self.splashScreen.setIconSize(QSize(128, 128))
        self.splashScreen.raise_()

        desktop = QApplication.desktop().availableGeometry()
        w, h = desktop.width(), desktop.height()
        self.move(w // 2 - self.width() // 2, h // 2 - self.height() // 2)

        self.show()
        QApplication.processEvents()

    def initInterface(self):
        self.warpInterface = YuanShenWidget(self)

    def initNavigation(self):

        self.addSubInterface(self.warpInterface, FIF.SHARE, self.tr('抽卡记录'))

        self.splashScreen.finish()

------具体的widget
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel
from qfluentwidgets import ScrollArea, PushButton
from qfluentwidgets import FluentIcon as FIF

from mautohelper.app.common.style_sheet import StyleSheet

class YuanShenWidget(ScrollArea):
    """YS"""

    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.view = QWidget(self)
        self.vBoxLayout = QVBoxLayout(self.view)
        self.titleLabel = QLabel(self.tr("抽卡记录"), self)

        self.warplink = None

        self.stateTooltip = None

        self.contentLabel = QLabel(parent)

        self.__initWidget()
        self.__connectSignalToSlot()

    def __initWidget(self):
        self.view.setObjectName('view')
        self.setViewportMargins(0, 140, 0, 20)
        self.setObjectName('YuanShenWidget')
        self.contentLabel.setObjectName('contentLabel')
        # self.titleLabel.setObjectName('warpLabel')
        StyleSheet.WARP_INTERFACE.apply(self)

        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setWidget(self.view)
        self.setWidgetResizable(True)
        self.contentLabel.setWordWrap(True)
        self.contentLabel.setMaximumWidth(800)

        self.vBoxLayout.setSpacing(8)
        self.vBoxLayout.setAlignment(Qt.AlignTop)
        self.vBoxLayout.addWidget(self.titleLabel, 0, Qt.AlignTop)

        self.vBoxLayout.setSpacing(28)
        self.vBoxLayout.setContentsMargins(36, 0, 36, 0)
        self.vBoxLayout.addWidget(self.contentLabel, 0, Qt.AlignTop)

    def __connectSignalToSlot(self):
        None
herui119110 commented 3 months ago

已自己学习解决