Closed atticus-lv closed 11 months ago
rt, 主题设置无法完整传递到自定义的subinterface(可以看到字体是白色的,但背景不是)
win11 22631
3.10.7
5.15.10
1.3.8
使用examples/gallery/window/ms_fluent_window/demo.py 进行测试 把下面提供的文件代码test_interface.py放入demo.py 同一目录下
test_interface.py
并替换 demo.py的部分代码
from test_interface import IconInterface class Window(MSFluentWindow): def __init__(self): super().__init__() # create sub interface self.homeInterface = Widget('Home Interface', self) self.appInterface = Widget('Application Interface', self) self.videoInterface = IconInterface(self) self.libraryInterface = Widget('library Interface', self) self.initNavigation() self.initWindow()
# coding:utf-8 from typing import List from PyQt5.QtCore import Qt, pyqtSignal from PyQt5.QtWidgets import QApplication, QFrame, QVBoxLayout, QLabel, QWidget, QHBoxLayout from qfluentwidgets import (FluentIcon, IconWidget, FlowLayout, isDarkTheme, setTheme, Theme, applyThemeColor, SmoothScrollArea, SearchLineEdit, StrongBodyLabel, ScrollArea, ImageLabel, CaptionLabel, ElevatedCardWidget, BodyLabel) from pathlib import Path # test_interface.py # 这里放gallery的icon icon_dir_path = r'C:\Users\atticus\Desktop\test\qt_client\view\test_icon' class EmojiCard(ElevatedCardWidget): """ Emoji card """ def __init__(self, iconPath: str, parent=None): super().__init__(parent) self.iconWidget = ImageLabel(iconPath, self) self.label = CaptionLabel(Path(iconPath).stem, self) self.iconWidget.scaledToHeight(68) self.vBoxLayout = QVBoxLayout(self) self.vBoxLayout.setAlignment(Qt.AlignCenter) self.vBoxLayout.addStretch(1) self.vBoxLayout.addWidget(self.iconWidget, 0, Qt.AlignCenter) self.vBoxLayout.addStretch(1) self.vBoxLayout.addWidget( self.label, 0, Qt.AlignHCenter | Qt.AlignBottom) self.setFixedSize(168, 176) class GalleryInterface(ScrollArea): """ Gallery interface """ def __init__(self, title: str, subtitle: str, parent=None): """ Parameters ---------- title: str The title of gallery subtitle: str The subtitle of gallery parent: QWidget parent widget """ super().__init__(parent=parent) self.view = QWidget(self) self.flowLayout = FlowLayout(self.view) self.flowLayout.setSpacing(6) self.flowLayout.setContentsMargins(30, 60, 30, 30) self.flowLayout.setAlignment(Qt.AlignVCenter) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setWidget(self.view) self.setWidgetResizable(True) self.view.setObjectName('view') for path in Path(icon_dir_path).glob('*.png'): card = EmojiCard(str(path), self) self.flowLayout.addWidget(card) setTheme(Theme.DARK) def scrollToCard(self, index: int): """ scroll to example card """ w = self.vBoxLayout.itemAt(index).widget() self.verticalScrollBar().setValue(w.y()) class IconInterface(GalleryInterface): """ Icon view """ def __init__(self, parent=None): super().__init__( title='test', subtitle="qfluentwidgets.common.icon", parent=parent ) self.setObjectName('Test Interface')
得使用样式表设置滚动区域背景以及滚动区域使用的widget背景为透明
谢谢,已解决
What happened?
rt, 主题设置无法完整传递到自定义的subinterface(可以看到字体是白色的,但背景不是)
Operation System
win11 22631
Python Version
3.10.7
PyQt/PySide Version
5.15.10
PyQt/PySide-Fluent-Widgets Version
1.3.8
How to Reproduce?
使用examples/gallery/window/ms_fluent_window/demo.py 进行测试 把下面提供的文件代码
test_interface.py
放入demo.py 同一目录下并替换 demo.py的部分代码
Minimum code