def paintEvent(self, event): """ Handle the paint event for the dock rubber band. """ painter = QPainter(self) opt = QStyleOption() opt.initFrom(self) self.style().drawPrimitive(QStyle.PE_Widget, opt, painter, self)
def updateSpacing(self): """ Update the layout spacing for the dock bar. This method will extract spacing value defined in the style sheet for the dock area and apply it to the spacing between the dock bars and the central widget. """ opt = QStyleOption() opt.initFrom(self) style = self.style() # hack to get the style sheet 'spacing' property. spacing = style.pixelMetric(QStyle.PM_ToolBarItemSpacing, opt, self) self.layout().setSpacing(spacing)
def styleOption(self): """ Get a filled style option for the button. Returns ------- result : QStyleOption A style option initialized for the current button state. """ opt = QStyleOption() opt.initFrom(self) opt.state |= QStyle.State_AutoRaise is_down = self.isDown() is_enabled = self.isEnabled() is_checked = self.isChecked() under_mouse = self.underMouse() if is_enabled and under_mouse and not is_checked and not is_down: opt.state |= QStyle.State_Raised if is_checked: opt.state |= QStyle.State_On if is_down: opt.state |= QStyle.State_Sunken return opt