def create_layout(self): ''' Creates the complete layout including all controls ''' self.title_label = ElidingLabel(text=self.dock_widget.windowTitle()) self.title_label.set_elide_mode(Qt.ElideRight) self.title_label.setObjectName("dockWidgetTabLabel") self.title_label.setAlignment(Qt.AlignCenter) self.close_button = QPushButton() self.close_button.setObjectName("tabCloseButton") set_button_icon(self.public.style(), self.close_button, QStyle.SP_TitleBarCloseButton) self.close_button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.close_button.setVisible(False) self.close_button.setToolTip("Close Tab") self.close_button.clicked.connect(self.public.close_requested) fm = QFontMetrics(self.title_label.font()) spacing = round(fm.height() / 4.0) # Fill the layout layout = QBoxLayout(QBoxLayout.LeftToRight) layout.setContentsMargins(2 * spacing, 0, 0, 0) layout.setSpacing(0) self.public.setLayout(layout) layout.addWidget(self.title_label, 1) layout.addSpacing(spacing) layout.addWidget(self.close_button) layout.addSpacing(round(spacing * 4.0 / 3.0)) layout.setAlignment(Qt.AlignCenter) self.title_label.setVisible(True)
def create_layout(self): ''' Creates the complete layout including all controls ''' self.title_label = ElidingLabel() self.title_label.set_elide_mode(Qt.ElideRight) self.title_label.setText("DockWidget->windowTitle()") self.title_label.setObjectName("floatingTitleLabel") self.title_label.setAlignment(Qt.AlignLeft) self.close_button = QPushButton() self.close_button.setObjectName("floatingTitleCloseButton") self.close_button.setFlat(True) # self.close_button.setAutoRaise(True) set_button_icon(self.public.style(), self.close_button, QStyle.SP_TitleBarCloseButton) self.close_button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.close_button.setVisible(True) self.close_button.setFocusPolicy(Qt.NoFocus) self.close_button.clicked.connect(self.public.close_requested) fm = QFontMetrics(self.title_label.font()) spacing = round(fm.height() / 4.0) # Fill the layout layout = QBoxLayout(QBoxLayout.LeftToRight) layout.setContentsMargins(6, 0, 0, 0) layout.setSpacing(0) self.public.setLayout(layout) layout.addWidget(self.title_label, 1) layout.addSpacing(spacing) layout.addWidget(self.close_button) layout.setAlignment(Qt.AlignCenter) self.title_label.setVisible(True)