From a7ad0e6006536a0145dcc243abd6d5ecbe1fdae2 Mon Sep 17 00:00:00 2001 From: muzing Date: Fri, 17 Nov 2023 22:21:16 +0800 Subject: [PATCH] Fix trailing-whitespace --- .../01-The_Meta-Object_System-元对象系统.md | 2 +- .../01-QWidget-控件的基类/09-QWidget-键盘输入焦点-2.py | 12 ++++++------ .../01-QComboBox-组合下拉框/06-QComboBox-信号.py | 14 +++++++------- .../01-QDialog-对话框基类/03-QDialog-槽、尺寸拖拽.py | 10 +++++----- .../02-QSS-样式表/01-QSS主题及编辑器.md | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/02-QtCore-非GUI的核心功能/01-The_Meta-Object_System-元对象系统.md b/02-QtCore-非GUI的核心功能/01-The_Meta-Object_System-元对象系统.md index ef2a6f0..f3d24e8 100644 --- a/02-QtCore-非GUI的核心功能/01-The_Meta-Object_System-元对象系统.md +++ b/02-QtCore-非GUI的核心功能/01-The_Meta-Object_System-元对象系统.md @@ -74,6 +74,6 @@ if (QLabel label = QLabel (obj)) { label.setText(tr("Ping")) ------ -© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the [GNU Free Documentation License version 1.3](https://www.gnu.org/licenses/fdl-1.3.html) as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. +© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the [GNU Free Documentation License version 1.3](https://www.gnu.org/licenses/fdl-1.3.html) as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. © 2022 zh_CN Translation by muzing\. diff --git a/03-QtWidgets-常用控件/01-QWidget-控件的基类/09-QWidget-键盘输入焦点-2.py b/03-QtWidgets-常用控件/01-QWidget-控件的基类/09-QWidget-键盘输入焦点-2.py index 7d0e4f3..991b21b 100644 --- a/03-QtWidgets-常用控件/01-QWidget-控件的基类/09-QWidget-键盘输入焦点-2.py +++ b/03-QtWidgets-常用控件/01-QWidget-控件的基类/09-QWidget-键盘输入焦点-2.py @@ -1,8 +1,3 @@ -import sys - -from PySide6 import QtWidgets -from PySide6.QtCore import Qt - """ QWidget 键盘输入焦点控制 @@ -14,7 +9,7 @@ QWidget 键盘输入焦点控制 https://doc.qt.io/qt-6/qwidget.html#setFocusProxy .setFocusPolicy(policy: Qt.FocusPolicy) 设置焦点策略,详见下方Qt.FocusPolicy -.focusPolicy() -> Qt.FocusPolicy 返回该控件的焦点策略 +.focusPolicy() -> Qt.FocusPolicy 返回该控件的焦点策略 Qt.FocusPolicy 具体分为如下数种: https://doc.qt.io/qt-6/qt.html#FocusPolicy-enum @@ -32,6 +27,11 @@ Qt.WheelFocus 补充:若只有一个控件设置为此策略,则需要当前 """ +import sys + +from PySide6 import QtWidgets +from PySide6.QtCore import Qt + class MyWidget(QtWidgets.QWidget): def __init__(self, *args, **kwargs): diff --git a/03-QtWidgets-常用控件/11-ComboBox-下拉框/01-QComboBox-组合下拉框/06-QComboBox-信号.py b/03-QtWidgets-常用控件/11-ComboBox-下拉框/01-QComboBox-组合下拉框/06-QComboBox-信号.py index 10a9639..1580faa 100644 --- a/03-QtWidgets-常用控件/11-ComboBox-下拉框/01-QComboBox-组合下拉框/06-QComboBox-信号.py +++ b/03-QtWidgets-常用控件/11-ComboBox-下拉框/01-QComboBox-组合下拉框/06-QComboBox-信号.py @@ -1,14 +1,10 @@ -import sys - -from PySide6 import QtCore, QtWidgets - """ QComboBox 信号 提供了多种精细的信号供使用 .activated(index: int) 当用户在组合下拉框中选中一个条目时发射此信号,索引作为参数传递。即使选中项未改变也会发射 - + .currentIndexChanged(index: int) 当当前索引由用户交互或编程方式改变时发射此信号,索引作为参数传递。 若combobox为空或当前索引已重置,则传递条目的 index 或 -1 @@ -18,11 +14,11 @@ QComboBox 信号 .editTextChanged(text: str) 当启用了可编辑模式,且编辑器中的文本发生改变时发射此信号,新的文本作为参数传递 - + .highlighted(index: int) 当用户高亮(光标移入或键盘选择)了弹出菜单中的某一条目时发射此信号 索引值作为参数传递 - + .textActivated(text: str) 当用户选择了条目之一时,发射此信号并将文本作为参数传递 即使选择未发生改变也会发射此信号 @@ -33,6 +29,10 @@ QComboBox 信号 """ +import sys + +from PySide6 import QtCore, QtWidgets + class MyWidget(QtWidgets.QWidget): def __init__(self, *args, **kwargs): diff --git a/03-QtWidgets-常用控件/12-Dialog-对话框/01-QDialog-对话框基类/03-QDialog-槽、尺寸拖拽.py b/03-QtWidgets-常用控件/12-Dialog-对话框/01-QDialog-对话框基类/03-QDialog-槽、尺寸拖拽.py index a70932c..cd9f73c 100644 --- a/03-QtWidgets-常用控件/12-Dialog-对话框/01-QDialog-对话框基类/03-QDialog-槽、尺寸拖拽.py +++ b/03-QtWidgets-常用控件/12-Dialog-对话框/01-QDialog-对话框基类/03-QDialog-槽、尺寸拖拽.py @@ -1,7 +1,3 @@ -import sys - -from PySide6 import QtCore, QtWidgets - """ QDialog 槽、结果、尺寸拖拽控件 @@ -14,7 +10,7 @@ QDialog有一组槽,用于显示、关闭对话框并返回结果: 则done()也将导致局部事件循环结束,且exec()返回r。 .exec() 将对话框作为模态对话框显示。(默认为应用程序级模态)此函数返回QDialog.Accepted或QDialog.Rejected。 尽量避免使用exec()函数,而用open()替代。因为open()是异步的,并且不会增加额外的事件循环 - + QDialog.result中保存了对话框获得的结果,也可以通过代码显式设置结果码: .result() -> int 获取模态对话框的结果码,QDialog.Accepted为1,QDialog.Rejected为0 .setResult(i: int) 将模态对话框的结果码设置为i @@ -30,6 +26,10 @@ QDialog可以指定是否在窗口右下角显示一个QSizeGrip控件,方便 """ +import sys + +from PySide6 import QtCore, QtWidgets + class MyWidget(QtWidgets.QWidget): def __init__(self, *args, **kwargs): diff --git a/05-QtWidgets-进阶话题/02-QSS-样式表/01-QSS主题及编辑器.md b/05-QtWidgets-进阶话题/02-QSS-样式表/01-QSS主题及编辑器.md index 0365495..ba4475b 100644 --- a/05-QtWidgets-进阶话题/02-QSS-样式表/01-QSS主题及编辑器.md +++ b/05-QtWidgets-进阶话题/02-QSS-样式表/01-QSS主题及编辑器.md @@ -67,7 +67,7 @@ class QSSLoader: ```python app = QApplication(sys.argv) window = MainWindow() - + style_file = './style.qss' style_sheet = QSSLoader.read_qss_file(style_file) window.setStyleSheet(style_sheet)