我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用PyQt5.QtCore.Qt.LeftToRight()。
def initUI(self): self.ui = Ui_Home() self.ui.setupUi(self) self.setGeometry( QStyle.alignedRect( Qt.LeftToRight, Qt.AlignCenter, self.size(), qApp.desktop().availableGeometry() ) ) self.show() self.ui.searchButton.clicked.connect(self.onSearch) self.ui.searchTextbox.returnPressed.connect(self.onSearch) self.ui.torrentList.selectionModel().selectionChanged.connect(self.onTorrentSelect) self.ui.torrentInfoMagnetLink.linkActivated.connect(self.onLinkClick) self.ui.torrentInfoTorrentLink.linkActivated.connect(self.onLinkClick)
def __init__(self, parent=None): super(EmbeddedDialog, self).__init__(parent) self.ui = Ui_embeddedDialog() self.ui.setupUi(self) self.ui.layoutDirection.setCurrentIndex(self.layoutDirection() != Qt.LeftToRight) for styleName in QStyleFactory.keys(): self.ui.style.addItem(styleName) if self.style().objectName().lower() == styleName.lower(): self.ui.style.setCurrentIndex(self.ui.style.count() -1) self.ui.layoutDirection.activated.connect(self.layoutDirectionChanged) self.ui.spacing.valueChanged.connect(self.spacingChanged) self.ui.fontComboBox.currentFontChanged.connect(self.fontChanged) self.ui.style.activated[str].connect(self.styleChanged)
def __init__(self,parent=None): super(QtBoolEdit, self).__init__(parent) self.m_checkBox = QCheckBox(self) self.m_textVisible = True lt = QHBoxLayout() if (QApplication.layoutDirection() == Qt.LeftToRight): lt.setContentsMargins(4, 0, 0, 0) else: lt.setContentsMargins(0, 0, 4, 0) lt.addWidget(self.m_checkBox) self.setLayout(lt) self.m_checkBox.toggled.connect(self.toggledSignal) self.setFocusProxy(self.m_checkBox) self.m_checkBox.setText(self.tr("True"))
def setupTreeViewEditorMargin(lt): DecorationMargin = 4 if (QApplication.layoutDirection() == Qt.LeftToRight): lt.setContentsMargins(DecorationMargin, 0, 0, 0) else: lt.setContentsMargins(0, 0, DecorationMargin, 0)
def layoutDirectionChanged(self, index): if index == 0: self.setLayoutDirection(Qt.LeftToRight) else: self.setLayoutDirection(Qt.RightToLeft)
def paint(self, painter, option, index): hasValue = True if (self.m_editorPrivate): property = self.m_editorPrivate.indexToProperty(index) if (property): hasValue = property.hasValue() opt = QStyleOptionViewItem(option) if ((self.m_editorPrivate and index.column() == 0) or not hasValue): property = self.m_editorPrivate.indexToProperty(index) if (property and property.isModified()): opt.font.setBold(True) opt.fontMetrics = QFontMetrics(opt.font) c = QColor() if (not hasValue and self.m_editorPrivate.markPropertiesWithoutValue()): c = opt.palette.color(QPalette.Dark) opt.palette.setColor(QPalette.Text, opt.palette.color(QPalette.BrightText)) else: c = self.m_editorPrivate.calculatedBackgroundColor(self.m_editorPrivate.indexToBrowserItem(index)) if (c.isValid() and (opt.features & QStyleOptionViewItem.Alternate)): c = c.lighter(112) if (c.isValid()): painter.fillRect(option.rect, c) opt.state &= ~QStyle.State_HasFocus if (index.column() == 1): item = self.m_editorPrivate.indexToItem(index) if (self.m_editedItem and (self.m_editedItem == item)): self.m_disablePainting = True super(QtPropertyEditorDelegate, self).paint(painter, opt, index) if (option.type): self.m_disablePainting = False opt.palette.setCurrentColorGroup(QPalette.Active) color = QApplication.style().styleHint(QStyle.SH_Table_GridLineColor, opt) painter.save() painter.setPen(QPen(color)) if (not self.m_editorPrivate or (not self.m_editorPrivate.lastColumn(index.column()) and hasValue)): if option.direction == Qt.LeftToRight: right = option.rect.right() else: right = option.rect.left() painter.drawLine(right, option.rect.y(), right, option.rect.bottom()) painter.restore()
def help_dialog(self): self.helpDialog = QDialog() self.helpDialog.setObjectName("self.helpDialog") self.helpDialog.setWindowModality(Qt.ApplicationModal) self.helpDialog.setFixedSize(362, 151) icon = QIcon() icon.addPixmap(QPixmap("../resource/logo.png"), QIcon.Normal, QIcon.Off) self.helpDialog.setWindowIcon(icon) self.helpDialog.setLayoutDirection(Qt.LeftToRight) self.helpDialog.setAutoFillBackground(False) self.helpDialog.setSizeGripEnabled(False) self.helpDialog.setModal(False) self.docButton = QPushButton(self.helpDialog) self.docButton.setGeometry(QRect(200, 100, 111, 41)) icon1 = QIcon() icon1.addPixmap(QPixmap("../resource/Doc.png"), QIcon.Normal, QIcon.Off) self.docButton.setIcon(icon1) self.docButton.setObjectName("docButton") self.tubeButton = QPushButton(self.helpDialog) self.tubeButton.setGeometry(QRect(50, 100, 111, 41)) icon2 = QIcon() icon2.addPixmap(QPixmap("../resource/YouTube.png"), QIcon.Normal, QIcon.Off) self.tubeButton.setIcon(icon2) self.tubeButton.setObjectName("tubeButton") self.label = QLabel(self.helpDialog) self.label.setGeometry(QRect(20, 10, 331, 21)) font = QFont() font.setPointSize(12) self.label.setFont(font) self.label.setObjectName("label") self.label_2 = QLabel(self.helpDialog) self.label_2.setGeometry(QRect(20, 30, 321, 21)) font = QFont() font.setPointSize(12) self.label_2.setFont(font) self.label_2.setObjectName("label_2") self.label_3 = QLabel(self.helpDialog) self.label_3.setGeometry(QRect(20, 50, 321, 20)) font = QFont() font.setPointSize(12) self.label_3.setFont(font) self.label_3.setObjectName("label_3") self.label_4 = QLabel(self.helpDialog) self.label_4.setGeometry(QRect(30, 80, 211, 17)) font = QFont() font.setPointSize(8) font.setItalic(True) self.label_4.setFont(font) self.label_4.setObjectName("label_4") self.retranslate_help_ui(self.helpDialog) QMetaObject.connectSlotsByName(self.helpDialog) self.docButton.clicked.connect(self.open_github) self.helpDialog.exec_() #help_dialog calls this inturn to set some labels messages