Stacked widget
| 199 | |
| 200 | |
| 201 | class ChildStackedWidget(QFrame): |
| 202 | """Stacked widget""" |
| 203 | |
| 204 | currentChanged = pyqtSignal(int) |
| 205 | |
| 206 | def __init__(self, parent=None): |
| 207 | super().__init__(parent=parent) |
| 208 | self.hBoxLayout = QHBoxLayout(self) |
| 209 | self.view = EraseStackedWidget(self) |
| 210 | |
| 211 | self.hBoxLayout.setContentsMargins(0, 0, 0, 0) |
| 212 | self.hBoxLayout.addWidget(self.view) |
| 213 | |
| 214 | self.view.currentChanged.connect(self.currentChanged) |
| 215 | self.setAttribute(Qt.WA_StyledBackground) |
| 216 | |
| 217 | def addWidget(self, widget): |
| 218 | """add widget to view""" |
| 219 | self.view.addWidget(widget) |
| 220 | |
| 221 | def widget(self, index: int): |
| 222 | return self.view.widget(index) |
| 223 | |
| 224 | def setCurrentWidget(self, widget, popOut=False): |
| 225 | if isinstance(widget, QAbstractScrollArea): |
| 226 | widget.verticalScrollBar().setValue(0) |
| 227 | |
| 228 | if not popOut: |
| 229 | self.view.setCurrentWidget(widget, duration=220) |
| 230 | else: |
| 231 | self.view.setCurrentWidget(widget, False, True, 220, QEasingCurve.BezierSpline) |
| 232 | |
| 233 | def setCurrentIndex(self, index, popOut=False): |
| 234 | self.setCurrentWidget(self.view.widget(index), popOut) |
| 235 | |
| 236 | def currentIndex(self): |
| 237 | return self.view.currentIndex() |
| 238 | |
| 239 | def currentWidget(self): |
| 240 | return self.view.currentWidget() |
| 241 | |
| 242 | def indexOf(self, widget): |
| 243 | return self.view.indexOf(widget) |
| 244 | |
| 245 | def count(self): |
| 246 | return self.view.count() |
| 247 | |
| 248 | |
| 249 | class MySmoothScrollArea(SmoothScrollArea): |