We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
:TabBar setScrollable 后鼠标滚轮可以滑动,但是用触摸板就无法滑动了,预期是通过触摸板也能滑动
Windows11
3.11
pyside6
1.6.1
使用官方examples/navigation/tab_view 可以复现
# coding:utf-8 import sys from PySide6.QtCore import Qt, QSize, QUrl, QPoint from PySide6.QtGui import QIcon, QDesktopServices, QColor from PySide6.QtWidgets import QHBoxLayout, QVBoxLayout, QApplication, QFrame, QStackedWidget from qfluentwidgets import (NavigationItemPosition, MessageBox, MSFluentTitleBar, MSFluentWindow, TabBar, SubtitleLabel, setFont, TabCloseButtonDisplayMode, IconWidget, TransparentDropDownToolButton, TransparentToolButton, setTheme, Theme, isDarkTheme) from qfluentwidgets import FluentIcon as FIF class Widget(QFrame): def __init__(self, text: str, parent=None): super().__init__(parent=parent) self.label = SubtitleLabel(text, self) self.hBoxLayout = QHBoxLayout(self) setFont(self.label, 24) self.label.setAlignment(Qt.AlignCenter) self.hBoxLayout.addWidget(self.label, 1, Qt.AlignCenter) self.setObjectName(text.replace(' ', '-')) class TabInterface(QFrame): """ Tab interface """ def __init__(self, text: str, icon, objectName, parent=None): super().__init__(parent=parent) self.iconWidget = IconWidget(icon, self) self.label = SubtitleLabel(text, self) self.iconWidget.setFixedSize(120, 120) self.vBoxLayout = QVBoxLayout(self) self.vBoxLayout.setAlignment(Qt.AlignCenter) self.vBoxLayout.setSpacing(30) self.vBoxLayout.addWidget(self.iconWidget, 0, Qt.AlignCenter) self.vBoxLayout.addWidget(self.label, 0, Qt.AlignCenter) setFont(self.label, 24) self.setObjectName(objectName) class CustomTitleBar(MSFluentTitleBar): """ Title bar with icon and title """ def __init__(self, parent): super().__init__(parent) # add buttons self.toolButtonLayout = QHBoxLayout() color = QColor(206, 206, 206) if isDarkTheme() else QColor(96, 96, 96) self.searchButton = TransparentToolButton(FIF.SEARCH_MIRROR.icon(color=color), self) self.forwardButton = TransparentToolButton(FIF.RIGHT_ARROW.icon(color=color), self) self.backButton = TransparentToolButton(FIF.LEFT_ARROW.icon(color=color), self) self.forwardButton.setDisabled(True) self.toolButtonLayout.setContentsMargins(20, 0, 20, 0) self.toolButtonLayout.setSpacing(15) self.toolButtonLayout.addWidget(self.searchButton) self.toolButtonLayout.addWidget(self.backButton) self.toolButtonLayout.addWidget(self.forwardButton) self.hBoxLayout.insertLayout(4, self.toolButtonLayout) # add tab bar self.tabBar = TabBar(self) self.tabBar.setMovable(True) self.tabBar.setScrollable(True) self.tabBar.setTabMaximumWidth(220) self.tabBar.setTabShadowEnabled(False) self.tabBar.setTabSelectedBackgroundColor(QColor(255, 255, 255, 125), QColor(255, 255, 255, 50)) # self.tabBar.setScrollable(True) # self.tabBar.setCloseButtonDisplayMode(TabCloseButtonDisplayMode.ON_HOVER) self.tabBar.tabCloseRequested.connect(self.tabBar.removeTab) self.tabBar.currentChanged.connect(lambda i: print(self.tabBar.tabText(i))) self.hBoxLayout.insertWidget(5, self.tabBar, 1) self.hBoxLayout.setStretch(6, 0) # add avatar self.avatar = TransparentDropDownToolButton('resource/shoko.png', self) self.avatar.setIconSize(QSize(26, 26)) self.avatar.setFixedHeight(30) self.hBoxLayout.insertWidget(7, self.avatar, 0, Qt.AlignRight) self.hBoxLayout.insertSpacing(8, 20) def canDrag(self, pos: QPoint): if not super().canDrag(pos): return False pos.setX(pos.x() - self.tabBar.x()) return not self.tabBar.tabRegion().contains(pos) class Window(MSFluentWindow): def __init__(self): self.isMicaEnabled = False super().__init__() self.setTitleBar(CustomTitleBar(self)) self.tabBar = self.titleBar.tabBar # type: TabBar # create sub interface self.homeInterface = QStackedWidget(self, objectName='homeInterface') self.appInterface = Widget('Application Interface', self) self.videoInterface = Widget('Video Interface', self) self.libraryInterface = Widget('library Interface', self) self.initNavigation() self.initWindow() def initNavigation(self): self.addSubInterface(self.homeInterface, FIF.HOME, '主页', FIF.HOME_FILL) self.addSubInterface(self.appInterface, FIF.APPLICATION, '应用') self.addSubInterface(self.videoInterface, FIF.VIDEO, '视频') self.addSubInterface(self.libraryInterface, FIF.BOOK_SHELF, '库', FIF.LIBRARY_FILL, NavigationItemPosition.BOTTOM) self.navigationInterface.addItem( routeKey='Help', icon=FIF.HELP, text='帮助', onClick=self.showMessageBox, selectable=False, position=NavigationItemPosition.BOTTOM, ) self.navigationInterface.setCurrentItem( self.homeInterface.objectName()) # add tab self.addTab('Heart', 'As long as you love me', icon='resource/Heart.png') self.tabBar.currentChanged.connect(self.onTabChanged) self.tabBar.tabAddRequested.connect(self.onTabAddRequested) def initWindow(self): self.resize(1100, 750) self.setWindowIcon(QIcon(':/qfluentwidgets/images/logo.png')) self.setWindowTitle('PyQt-Fluent-Widgets') desktop = QApplication.screens()[0].availableGeometry() w, h = desktop.width(), desktop.height() self.move(w//2 - self.width()//2, h//2 - self.height()//2) def showMessageBox(self): w = MessageBox( '支持作者🥰', '个人开发不易,如果这个项目帮助到了您,可以考虑请作者喝一瓶快乐水🥤。您的支持就是作者开发和维护项目的动力🚀', self ) w.yesButton.setText('来啦老弟') w.cancelButton.setText('下次一定') if w.exec(): QDesktopServices.openUrl(QUrl("https://afdian.net/a/zhiyiYo")) def onTabChanged(self, index: int): objectName = self.tabBar.currentTab().routeKey() self.homeInterface.setCurrentWidget(self.findChild(TabInterface, objectName)) self.stackedWidget.setCurrentWidget(self.homeInterface) def onTabAddRequested(self): text = f'硝子酱一级棒卡哇伊×{self.tabBar.count()}' self.addTab(text, text, 'resource/Smiling_with_heart.png') def addTab(self, routeKey, text, icon): self.tabBar.addTab(routeKey, text, icon) self.homeInterface.addWidget(TabInterface(text, icon, routeKey, self)) if __name__ == '__main__': # setTheme(Theme.DARK) app = QApplication(sys.argv) w = Window() w.show() app.exec()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
What happened?
:TabBar setScrollable 后鼠标滚轮可以滑动,但是用触摸板就无法滑动了,预期是通过触摸板也能滑动
Operation System
Windows11
Python Version
3.11
PyQt/PySide Version
pyside6
PyQt/PySide-Fluent-Widgets Version
1.6.1
How to Reproduce?
使用官方examples/navigation/tab_view 可以复现
Minimum code
The text was updated successfully, but these errors were encountered: