我们从Python开源项目中,提取了以下21个代码示例,用于说明如何使用PyQt5.QtCore.Qt.ScrollBarAlwaysOff()。
def __init__(self, parent=None, frame=QtWidgets.QFrame.Box): super(FIRSTUI.ScrollWidget, self).__init__() # Container Widget widget = QtWidgets.QWidget() # Layout of Container Widget self.layout = QtWidgets.QVBoxLayout(self) self.layout.setContentsMargins(0, 0, 0, 0) widget.setLayout(self.layout) # Scroll Area Properties scroll = QtWidgets.QScrollArea() scroll.setFrameShape(frame) scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) scroll.setWidgetResizable(True) scroll.setWidget(widget) # Scroll Area Layer add scroll_layout = QtWidgets.QVBoxLayout(self) scroll_layout.addWidget(scroll) scroll_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(scroll_layout)
def setWrapLines(self, value): """ Sets the widget to wrap glyphs at the viewport’s *width* boundary if *value* is true. The default is false. """ self._wrapLines = value scrollArea = self._scrollArea if scrollArea is not None: if value: scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) else: scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.adjustSize() self.update()
def setupWidget(self): desktop = QApplication.desktop() screenRect = desktop.screenGeometry(desktop.primaryScreen()) windowRect = QRect(0, 0, 800, 600) if screenRect.width() < 800: windowRect.setWidth(screenRect.width()) if screenRect.height() < 600: windowRect.setHeight(screenRect.height()) windowRect.moveCenter(screenRect.center()) self.setGeometry(windowRect) self.setMinimumSize(80, 60) self.setWindowTitle("PyQt Examples") self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setFrameStyle(QFrame.NoFrame) self.setRenderingSystem() self.updateTimer.timeout.connect(self.tick)
def create_layout(self): self.horizontal_groupbox = QGroupBox("Enter the search query") layout = QVBoxLayout() self.line_edit = QLineEdit(self) layout.addWidget(self.line_edit) self.line_edit.editingFinished.connect(self.search) self.recommendations = QLabel("Other recommendations: [Currently in development]") layout.addWidget(self.recommendations) self.horizontal_groupbox.setLayout(layout) self.scroll_area = QScrollArea() self.scroll_area.setWidgetResizable(True) self.scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.scroll_area.setMinimumSize(600, 400) # TODO: Replace by proper scaling self.content_area = ResultWidget(self.scroll_area) self.scroll_area.setWidget(self.content_area)
def __init__(self, parent=None, flags=Qt.WindowCloseButtonHint): super(SettingsDialog, self).__init__(parent.parent, flags) self.parent = parent self.settings = self.parent.settings self.theme = self.parent.theme self.setObjectName('settingsdialog') self.setWindowTitle('Settings - {0}'.format(qApp.applicationName())) self.categories = QListWidget(self) self.categories.setResizeMode(QListView.Fixed) self.categories.setStyleSheet('QListView::item { text-decoration: none; }') self.categories.setAttribute(Qt.WA_MacShowFocusRect, False) self.categories.setObjectName('settingsmenu') self.categories.setUniformItemSizes(True) self.categories.setMouseTracking(True) self.categories.setViewMode(QListView.IconMode) self.categories.setIconSize(QSize(90, 60)) self.categories.setMovement(QListView.Static) self.categories.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.pages = QStackedWidget(self) self.pages.addWidget(GeneralPage(self)) self.pages.addWidget(VideoPage(self)) self.pages.addWidget(ThemePage(self)) self.pages.addWidget(LogsPage(self)) self.initCategories() horizontalLayout = QHBoxLayout() horizontalLayout.addWidget(self.categories) horizontalLayout.addWidget(self.pages, 1) buttons = QDialogButtonBox(QDialogButtonBox.Ok, self) buttons.accepted.connect(self.close) mainLayout = QVBoxLayout() mainLayout.addLayout(horizontalLayout) mainLayout.addWidget(buttons) self.setLayout(mainLayout)
def __init__(self, scene): super().__init__(scene) self.resize(self.viewWidth, self.viewHeight) self.setWindowTitle('thegame') self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # so that mouseMoveEvent is always triggered self.setMouseTracking(True) self.keys = scene.keys self.initAbilityButtons()
def __init__(self, parent=None): super().__init__(parent) self.horizontalHeader().setVisible(False) self.verticalHeader().setVisible(False) self.verticalHeader().setDefaultSectionSize(16) self.horizontalHeader().setDefaultSectionSize(23) self.setStyleSheet("QTableView {background-color: transparent;}") self.setShowGrid(False) self.setSelectionMode(QAbstractItemView.SingleSelection) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setAutoScroll(False)
def __init__(self): super(FrameCapture, self).__init__() self._percent = 0 self._page = QWebPage() self._page.mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff) self._page.mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff) self._page.loadProgress.connect(self.printProgress) self._page.loadFinished.connect(self.saveResult)
def __init__(self): super(PrintView, self).__init__() self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
def __init__(self, parent=None): super().__init__(parent) width, height = 800, 800 self.setGeometry(width, height, width, height) # configs, can be changed at runtime self.circle_line_color = Qt.gray self.crosshair_line_color = Qt.gray self.text_label_color = Qt.darkGreen self.measured_distances_color = Qt.green self.circle_count = 10 self.dot_width = 10 self.line_width = 1 self.distance_measurement_angle = 15 self.measurement_angle = 10 # degrees that one sensor covers self.fade_out_time = 4 # older measurements will fade out over this time self.add_text_labels = False # data self.measurements = [] self.added_time = dict() # measurement -> timestamp # drawing timer self.timer = QTimer() self.timer.setInterval(80) self.timer.timeout.connect(self.draw_radar) self.timer.start() # internal canvas setup self.layout = QHBoxLayout() self.setLayout(self.layout) self.scene = QGraphicsScene() self.scene.setSceneRect(0, 0, width, height) self.canvas = QGraphicsView() self.canvas.setRenderHint(QPainter.Antialiasing) self.canvas.setFixedSize(width, height) self.canvas.setAlignment(Qt.AlignLeft) self.canvas.setScene(self.scene) self.canvas.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.canvas.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.layout.addWidget(self.canvas) # initial rendering self.draw_radar()
def __init__(self, media, parent=None, flags=Qt.Dialog | Qt.WindowCloseButtonHint): super(VideoInfo, self).__init__(parent, flags) self.logger = logging.getLogger(__name__) self.media = media self.parent = parent self.setObjectName('videoinfo') self.setContentsMargins(0, 0, 0, 0) self.setWindowModality(Qt.ApplicationModal) self.setWindowTitle('Media information - {}'.format(os.path.basename(self.media))) self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.setMinimumSize(self.modes.get(self.parent.parent.scale)) metadata = '''<style> table { font-family: "Noto Sans UI", sans-serif; font-size: 13px; margin-top: -10px; } td i { font-family: "Noto Sans UI", sans-serif; font-weight: normal; font-style: normal; text-align: right; color: %s; white-space: nowrap; } td { font-weight: normal; text-align: right; } td + td { text-align: left; } h1, h2, h3 { color: %s; } </style> <div align="center">%s</div>''' % ('#C681D5' if self.parent.theme == 'dark' else '#642C68', '#C681D5' if self.parent.theme == 'dark' else '#642C68', self.parent.videoService.mediainfo(self.media)) content = QTextBrowser(self.parent) content.setStyleSheet('QTextBrowser { border: none; background-color: transparent; }') content.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) content.setHtml(metadata) keyframesButton = QPushButton('View keyframes', self) keyframesButton.clicked.connect(self.showKeyframes) okButton = QDialogButtonBox(QDialogButtonBox.Ok) okButton.accepted.connect(self.close) button_layout = QHBoxLayout() mediainfo_version = self.parent.videoService.cmdExec(self.parent.videoService.backends.mediainfo, '--version', True) if len(mediainfo_version) >= 2: mediainfo_version = mediainfo_version.split('\n')[1] mediainfo_label = QLabel('<div style="font-size:11px;"><b>Media information by:</b><br/>%s @ ' % mediainfo_version + '<a href="https://mediaarea.net" target="_blank">' + 'mediaarea.net</a></div>') button_layout.addWidget(mediainfo_label) button_layout.addStretch(1) button_layout.addWidget(keyframesButton) button_layout.addWidget(okButton) layout = QVBoxLayout() layout.addWidget(content) layout.addLayout(button_layout) self.setLayout(layout)
def __init__(self, parent=None): super().__init__() self.resize((settings().value("Player/resize") or QSize(640, 480))) self.move((settings().value("Player/position") or QPoint(250, 150))) self.setWindowTitle("Pisi Player") self.setWindowIcon(QIcon(":/data/images/pisiplayer.svg")) self.setStyleSheet("background-color: black; border: none;") self.setScene(QGraphicsScene()) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setAcceptDrops(True) self.subtitleitem = SubtitleItemText(self) self.player = Player(self) self.scene().addItem(self.player) self.scene().addItem(self.subtitleitem) self.bar = Bar(self) self.scene().addWidget(self.bar) self.player.player.durationChanged.connect(self.bar.videoSliderMax) self.player.player.positionChanged.connect(self.bar.videoSliderValue) self.player.player.mutedChanged.connect(self.bar.mutedChange) self.player.player.stateChanged.connect(self.bar.playingState) self.player.player.volumeChanged.connect(self.bar.volumeSlider) self.bar.play_and_pause_button.clicked.connect(self.playOrPause) self.bar.sound_button.clicked.connect(self.player.mutedState) self.bar.sound_volume_slider.valueChanged.connect(self.player.setVolume) self.bar.video_slider.sliderMoved.connect(self.player.sliderChanged) self.player.subtitlePos.connect(self.subtitleitem.positionValue) self.player.isSubtitle.connect(self.bar.cc_button.setVisible) self.cursorTimer = QTimer(self) self.cursorTimer.timeout.connect(self.mouseAndBarHideOrShow) self.cursorTimer.start(3000) self.player.playerPlayOrOpen(qApp.arguments()) self.settings_dialog = SettingsDialog(self) self.tube_dialog = TubeDialog(self) self.cc_dialog = CCDialog(self) self.scene().addWidget(self.cc_dialog) self.cc_dialog.subtitleCodecChanged.connect(self.subtitleitem.reParse) self.settings_dialog.settingsChanged.connect(self.subtitleitem.settingsChanged)
def __init__(self): super(MainWindow, self).__init__() centralWidget = QWidget() self.setCentralWidget(centralWidget) self.glWidget = GLWidget() self.pixmapLabel = QLabel() self.glWidgetArea = QScrollArea() self.glWidgetArea.setWidget(self.glWidget) self.glWidgetArea.setWidgetResizable(True) self.glWidgetArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.glWidgetArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.glWidgetArea.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) self.glWidgetArea.setMinimumSize(50, 50) self.pixmapLabelArea = QScrollArea() self.pixmapLabelArea.setWidget(self.pixmapLabel) self.pixmapLabelArea.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) self.pixmapLabelArea.setMinimumSize(50, 50) xSlider = self.createSlider(self.glWidget.xRotationChanged, self.glWidget.setXRotation) ySlider = self.createSlider(self.glWidget.yRotationChanged, self.glWidget.setYRotation) zSlider = self.createSlider(self.glWidget.zRotationChanged, self.glWidget.setZRotation) self.createActions() self.createMenus() centralLayout = QGridLayout() centralLayout.addWidget(self.glWidgetArea, 0, 0) centralLayout.addWidget(self.pixmapLabelArea, 0, 1) centralLayout.addWidget(xSlider, 1, 0, 1, 2) centralLayout.addWidget(ySlider, 2, 0, 1, 2) centralLayout.addWidget(zSlider, 3, 0, 1, 2) centralWidget.setLayout(centralLayout) xSlider.setValue(15 * 16) ySlider.setValue(345 * 16) zSlider.setValue(0 * 16) self.setWindowTitle("Grabber") self.resize(400, 300)