diff --git a/仿QQ设置面板/.README.md.html b/仿QQ设置面板/.README.md.html
new file mode 100644
index 0000000..ee499c0
--- /dev/null
+++ b/仿QQ设置面板/.README.md.html
@@ -0,0 +1,660 @@
+
+
+
+
+D:\Workspace\PyQt\仿QQ设置面板\.README.md.html
+
+
+
+
+
+
+
+
+
+
+ 仿QQ设置面板简单例子
+左侧: 使用QListWidget点击左侧时得到索引,然后根据索引去找右侧的widget_0之类的
+右侧: 使用QScrollArea控件,设置QVBoxLayout布局,然后一次添加Widget
+事件:
+
+ -
+
+ - 绑定左侧QListWidget的itemClicked的到该item的索引
+
+ -
+
+ - 绑定右侧滚动条的valueChanged事件得到pos
+
+
+注意:当itemClicked时定位滚动条的值时,需要设置一个标志位用来避免valueChanged重复调用item的定位
+ 截图
+
+
+
diff --git a/仿QQ设置面板/README.md b/仿QQ设置面板/README.md
new file mode 100644
index 0000000..e9da35a
--- /dev/null
+++ b/仿QQ设置面板/README.md
@@ -0,0 +1,16 @@
+# 仿QQ设置面板简单例子
+
+左侧:
+使用QListWidget点击左侧时得到索引,然后根据索引去找右侧的widget_0之类的
+
+右侧:
+使用QScrollArea控件,设置QVBoxLayout布局,然后一次添加Widget
+
+事件:
+ - 1. 绑定左侧QListWidget的itemClicked的到该item的索引
+ - 2. 绑定右侧滚动条的valueChanged事件得到pos
+
+注意:当itemClicked时定位滚动条的值时,需要设置一个标志位用来避免valueChanged重复调用item的定位
+
+## 截图
+![截图](ScreenShot/1.gif)
\ No newline at end of file
diff --git a/仿QQ设置面板/ScreenShot/1.gif b/仿QQ设置面板/ScreenShot/1.gif
new file mode 100644
index 0000000..a238e68
Binary files /dev/null and b/仿QQ设置面板/ScreenShot/1.gif differ
diff --git a/仿QQ设置面板/SettingUi.py b/仿QQ设置面板/SettingUi.py
index 3852b42..4da4b6b 100644
--- a/仿QQ设置面板/SettingUi.py
+++ b/仿QQ设置面板/SettingUi.py
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'setting.ui'
#
-# Created by: PyQt5 UI code generator 5.10.1
+# Created by: PyQt5 UI code generator 5.5.1
#
# WARNING! All changes made in this file will be lost!
@@ -11,13 +11,15 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Setting(object):
def setupUi(self, Setting):
Setting.setObjectName("Setting")
- Setting.resize(1022, 821)
+ Setting.resize(498, 498)
self.horizontalLayout = QtWidgets.QHBoxLayout(Setting)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.listWidget = QtWidgets.QListWidget(Setting)
self.listWidget.setFrameShape(QtWidgets.QFrame.NoFrame)
+ self.listWidget.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
+ self.listWidget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.listWidget.setObjectName("listWidget")
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
@@ -47,105 +49,100 @@ class Ui_Setting(object):
self.listWidget.addItem(item)
self.horizontalLayout.addWidget(self.listWidget)
self.scrollArea = QtWidgets.QScrollArea(Setting)
- self.scrollArea.setStyleSheet("#titleLabel1,#titleLabel2,#titleLabel3,#titleLabel4,#titleLabel5,#titleLabel6,#titleLabel7,#titleLabel8 {\n"
-" min-width: 100px;\n"
-" max-width: 100px;\n"
-" background-color: red;\n"
-"}")
self.scrollArea.setFrameShape(QtWidgets.QFrame.NoFrame)
self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
- self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, -700, 613, 1521))
+ self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, -810, 460, 1308))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.verticalLayout = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents)
self.verticalLayout.setContentsMargins(35, 20, 35, 20)
self.verticalLayout.setSpacing(20)
self.verticalLayout.setObjectName("verticalLayout")
- self.widget = QtWidgets.QWidget(self.scrollAreaWidgetContents)
- self.widget.setObjectName("widget")
- self.formLayout = QtWidgets.QFormLayout(self.widget)
+ self.widget_0 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
+ self.widget_0.setObjectName("widget_0")
+ self.formLayout = QtWidgets.QFormLayout(self.widget_0)
self.formLayout.setContentsMargins(0, 0, 0, 0)
self.formLayout.setObjectName("formLayout")
- self.titleLabel1 = QtWidgets.QLabel(self.widget)
+ self.titleLabel1 = QtWidgets.QLabel(self.widget_0)
self.titleLabel1.setObjectName("titleLabel1")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel1)
- self.CheckBox = QtWidgets.QCheckBox(self.widget)
+ self.CheckBox = QtWidgets.QCheckBox(self.widget_0)
self.CheckBox.setObjectName("CheckBox")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.CheckBox)
- self.checkBox = QtWidgets.QCheckBox(self.widget)
+ self.checkBox = QtWidgets.QCheckBox(self.widget_0)
self.checkBox.setChecked(True)
self.checkBox.setObjectName("checkBox")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox)
- self.checkBox_2 = QtWidgets.QCheckBox(self.widget)
+ self.checkBox_2 = QtWidgets.QCheckBox(self.widget_0)
self.checkBox_2.setChecked(True)
self.checkBox_2.setObjectName("checkBox_2")
self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_2)
- self.checkBox_3 = QtWidgets.QCheckBox(self.widget)
+ self.checkBox_3 = QtWidgets.QCheckBox(self.widget_0)
self.checkBox_3.setObjectName("checkBox_3")
self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_3)
- self.checkBox_4 = QtWidgets.QCheckBox(self.widget)
+ self.checkBox_4 = QtWidgets.QCheckBox(self.widget_0)
self.checkBox_4.setObjectName("checkBox_4")
self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.checkBox_4)
- self.checkBox_5 = QtWidgets.QCheckBox(self.widget)
+ self.checkBox_5 = QtWidgets.QCheckBox(self.widget_0)
self.checkBox_5.setObjectName("checkBox_5")
self.formLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.checkBox_5)
- self.checkBox_6 = QtWidgets.QCheckBox(self.widget)
+ self.checkBox_6 = QtWidgets.QCheckBox(self.widget_0)
self.checkBox_6.setObjectName("checkBox_6")
self.formLayout.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.checkBox_6)
- self.verticalLayout.addWidget(self.widget)
- self.widget_7 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
- self.widget_7.setObjectName("widget_7")
- self.formLayout_8 = QtWidgets.QFormLayout(self.widget_7)
+ self.verticalLayout.addWidget(self.widget_0)
+ self.widget_1 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
+ self.widget_1.setObjectName("widget_1")
+ self.formLayout_8 = QtWidgets.QFormLayout(self.widget_1)
self.formLayout_8.setContentsMargins(0, 0, 0, 0)
self.formLayout_8.setObjectName("formLayout_8")
- self.titleLabel2 = QtWidgets.QLabel(self.widget_7)
+ self.titleLabel2 = QtWidgets.QLabel(self.widget_1)
self.titleLabel2.setObjectName("titleLabel2")
self.formLayout_8.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel2)
- self.checkBox_26 = QtWidgets.QCheckBox(self.widget_7)
+ self.checkBox_26 = QtWidgets.QCheckBox(self.widget_1)
self.checkBox_26.setObjectName("checkBox_26")
self.formLayout_8.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.checkBox_26)
- self.checkBox_27 = QtWidgets.QCheckBox(self.widget_7)
+ self.checkBox_27 = QtWidgets.QCheckBox(self.widget_1)
self.checkBox_27.setObjectName("checkBox_27")
self.formLayout_8.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_27)
- self.checkBox_28 = QtWidgets.QCheckBox(self.widget_7)
+ self.checkBox_28 = QtWidgets.QCheckBox(self.widget_1)
self.checkBox_28.setObjectName("checkBox_28")
self.formLayout_8.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_28)
- self.checkBox_29 = QtWidgets.QCheckBox(self.widget_7)
+ self.checkBox_29 = QtWidgets.QCheckBox(self.widget_1)
self.checkBox_29.setObjectName("checkBox_29")
self.formLayout_8.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_29)
- self.label_10 = QtWidgets.QLabel(self.widget_7)
+ self.label_10 = QtWidgets.QLabel(self.widget_1)
self.label_10.setObjectName("label_10")
self.formLayout_8.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.label_10)
- self.right1 = QtWidgets.QRadioButton(self.widget_7)
+ self.right1 = QtWidgets.QRadioButton(self.widget_1)
self.right1.setObjectName("right1")
self.formLayout_8.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.right1)
- self.right2 = QtWidgets.QRadioButton(self.widget_7)
+ self.right2 = QtWidgets.QRadioButton(self.widget_1)
self.right2.setChecked(True)
self.right2.setObjectName("right2")
self.formLayout_8.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.right2)
- self.label_11 = QtWidgets.QLabel(self.widget_7)
+ self.label_11 = QtWidgets.QLabel(self.widget_1)
self.label_11.setObjectName("label_11")
self.formLayout_8.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.label_11)
- self.right3 = QtWidgets.QPushButton(self.widget_7)
+ self.right3 = QtWidgets.QPushButton(self.widget_1)
self.right3.setObjectName("right3")
self.formLayout_8.setWidget(8, QtWidgets.QFormLayout.FieldRole, self.right3)
- self.verticalLayout.addWidget(self.widget_7)
- self.widget_8 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
- self.widget_8.setObjectName("widget_8")
- self.formLayout_9 = QtWidgets.QFormLayout(self.widget_8)
+ self.verticalLayout.addWidget(self.widget_1)
+ self.widget_2 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
+ self.widget_2.setObjectName("widget_2")
+ self.formLayout_9 = QtWidgets.QFormLayout(self.widget_2)
self.formLayout_9.setContentsMargins(0, 0, 0, 0)
self.formLayout_9.setObjectName("formLayout_9")
- self.titleLabel3 = QtWidgets.QLabel(self.widget_8)
+ self.titleLabel3 = QtWidgets.QLabel(self.widget_2)
self.titleLabel3.setObjectName("titleLabel3")
self.formLayout_9.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel3)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
- self.label_13 = QtWidgets.QLabel(self.widget_8)
+ self.label_13 = QtWidgets.QLabel(self.widget_2)
self.label_13.setObjectName("label_13")
self.horizontalLayout_2.addWidget(self.label_13)
- self.comboBox = QtWidgets.QComboBox(self.widget_8)
+ self.comboBox = QtWidgets.QComboBox(self.widget_2)
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("")
self.comboBox.addItem("")
@@ -154,186 +151,237 @@ class Ui_Setting(object):
self.comboBox.addItem("")
self.comboBox.addItem("")
self.horizontalLayout_2.addWidget(self.comboBox)
+ spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.horizontalLayout_2.addItem(spacerItem)
self.formLayout_9.setLayout(0, QtWidgets.QFormLayout.FieldRole, self.horizontalLayout_2)
- self.checkBox_30 = QtWidgets.QCheckBox(self.widget_8)
+ self.checkBox_30 = QtWidgets.QCheckBox(self.widget_2)
self.checkBox_30.setObjectName("checkBox_30")
self.formLayout_9.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_30)
- self.right4 = QtWidgets.QLabel(self.widget_8)
+ self.right4 = QtWidgets.QLabel(self.widget_2)
self.right4.setObjectName("right4")
self.formLayout_9.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.right4)
- self.checkBox_31 = QtWidgets.QCheckBox(self.widget_8)
+ self.checkBox_31 = QtWidgets.QCheckBox(self.widget_2)
self.checkBox_31.setObjectName("checkBox_31")
self.formLayout_9.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_31)
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
- self.pushButton_5 = QtWidgets.QPushButton(self.widget_8)
+ self.pushButton_5 = QtWidgets.QPushButton(self.widget_2)
self.pushButton_5.setObjectName("pushButton_5")
self.horizontalLayout_3.addWidget(self.pushButton_5)
- self.pushButton_4 = QtWidgets.QPushButton(self.widget_8)
+ self.pushButton_4 = QtWidgets.QPushButton(self.widget_2)
self.pushButton_4.setObjectName("pushButton_4")
self.horizontalLayout_3.addWidget(self.pushButton_4)
+ spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.horizontalLayout_3.addItem(spacerItem1)
self.formLayout_9.setLayout(4, QtWidgets.QFormLayout.FieldRole, self.horizontalLayout_3)
- self.verticalLayout.addWidget(self.widget_8)
- self.widget_2 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
- self.widget_2.setObjectName("widget_2")
- self.formLayout_2 = QtWidgets.QFormLayout(self.widget_2)
- self.formLayout_2.setContentsMargins(0, 0, 0, 0)
- self.formLayout_2.setObjectName("formLayout_2")
- self.titleLabel4 = QtWidgets.QLabel(self.widget_2)
- self.titleLabel4.setObjectName("titleLabel4")
- self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel4)
- self.CheckBox_2 = QtWidgets.QCheckBox(self.widget_2)
- self.CheckBox_2.setChecked(True)
- self.CheckBox_2.setObjectName("CheckBox_2")
- self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.CheckBox_2)
- self.checkBox_7 = QtWidgets.QCheckBox(self.widget_2)
- self.checkBox_7.setObjectName("checkBox_7")
- self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_7)
- self.checkBox_8 = QtWidgets.QCheckBox(self.widget_2)
- self.checkBox_8.setObjectName("checkBox_8")
- self.formLayout_2.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_8)
- self.checkBox_9 = QtWidgets.QCheckBox(self.widget_2)
- self.checkBox_9.setChecked(True)
- self.checkBox_9.setObjectName("checkBox_9")
- self.formLayout_2.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_9)
- self.checkBox_10 = QtWidgets.QCheckBox(self.widget_2)
- self.checkBox_10.setChecked(True)
- self.checkBox_10.setObjectName("checkBox_10")
- self.formLayout_2.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.checkBox_10)
- self.checkBox_11 = QtWidgets.QCheckBox(self.widget_2)
- self.checkBox_11.setChecked(True)
- self.checkBox_11.setObjectName("checkBox_11")
- self.formLayout_2.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.checkBox_11)
- self.checkBox_12 = QtWidgets.QCheckBox(self.widget_2)
- self.checkBox_12.setChecked(True)
- self.checkBox_12.setObjectName("checkBox_12")
- self.formLayout_2.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.checkBox_12)
- self.checkBox_13 = QtWidgets.QCheckBox(self.widget_2)
- self.checkBox_13.setChecked(True)
- self.checkBox_13.setObjectName("checkBox_13")
- self.formLayout_2.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.checkBox_13)
- self.checkBox_14 = QtWidgets.QCheckBox(self.widget_2)
- self.checkBox_14.setChecked(True)
- self.checkBox_14.setObjectName("checkBox_14")
- self.formLayout_2.setWidget(8, QtWidgets.QFormLayout.FieldRole, self.checkBox_14)
- self.checkBox_15 = QtWidgets.QCheckBox(self.widget_2)
- self.checkBox_15.setChecked(True)
- self.checkBox_15.setObjectName("checkBox_15")
- self.formLayout_2.setWidget(9, QtWidgets.QFormLayout.FieldRole, self.checkBox_15)
self.verticalLayout.addWidget(self.widget_2)
self.widget_3 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_3.setObjectName("widget_3")
- self.formLayout_3 = QtWidgets.QFormLayout(self.widget_3)
- self.formLayout_3.setContentsMargins(0, 0, 0, 0)
- self.formLayout_3.setObjectName("formLayout_3")
- self.titleLabel5 = QtWidgets.QLabel(self.widget_3)
- self.titleLabel5.setObjectName("titleLabel5")
- self.formLayout_3.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel5)
- self.checkBox_16 = QtWidgets.QCheckBox(self.widget_3)
- self.checkBox_16.setChecked(True)
- self.checkBox_16.setObjectName("checkBox_16")
- self.formLayout_3.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.checkBox_16)
- self.checkBox_17 = QtWidgets.QCheckBox(self.widget_3)
- self.checkBox_17.setChecked(True)
- self.checkBox_17.setObjectName("checkBox_17")
- self.formLayout_3.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_17)
- self.checkBox_18 = QtWidgets.QCheckBox(self.widget_3)
- self.checkBox_18.setChecked(True)
- self.checkBox_18.setObjectName("checkBox_18")
- self.formLayout_3.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_18)
- self.checkBox_19 = QtWidgets.QCheckBox(self.widget_3)
- self.checkBox_19.setChecked(True)
- self.checkBox_19.setObjectName("checkBox_19")
- self.formLayout_3.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_19)
+ self.formLayout_2 = QtWidgets.QFormLayout(self.widget_3)
+ self.formLayout_2.setContentsMargins(0, 0, 0, 0)
+ self.formLayout_2.setObjectName("formLayout_2")
+ self.titleLabel4 = QtWidgets.QLabel(self.widget_3)
+ self.titleLabel4.setObjectName("titleLabel4")
+ self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel4)
+ self.CheckBox_2 = QtWidgets.QCheckBox(self.widget_3)
+ self.CheckBox_2.setChecked(True)
+ self.CheckBox_2.setObjectName("CheckBox_2")
+ self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.CheckBox_2)
+ self.checkBox_7 = QtWidgets.QCheckBox(self.widget_3)
+ self.checkBox_7.setObjectName("checkBox_7")
+ self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_7)
+ self.checkBox_8 = QtWidgets.QCheckBox(self.widget_3)
+ self.checkBox_8.setObjectName("checkBox_8")
+ self.formLayout_2.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_8)
+ self.checkBox_9 = QtWidgets.QCheckBox(self.widget_3)
+ self.checkBox_9.setChecked(True)
+ self.checkBox_9.setObjectName("checkBox_9")
+ self.formLayout_2.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_9)
+ self.checkBox_10 = QtWidgets.QCheckBox(self.widget_3)
+ self.checkBox_10.setChecked(True)
+ self.checkBox_10.setObjectName("checkBox_10")
+ self.formLayout_2.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.checkBox_10)
+ self.checkBox_11 = QtWidgets.QCheckBox(self.widget_3)
+ self.checkBox_11.setChecked(True)
+ self.checkBox_11.setObjectName("checkBox_11")
+ self.formLayout_2.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.checkBox_11)
+ self.checkBox_12 = QtWidgets.QCheckBox(self.widget_3)
+ self.checkBox_12.setChecked(True)
+ self.checkBox_12.setObjectName("checkBox_12")
+ self.formLayout_2.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.checkBox_12)
+ self.checkBox_13 = QtWidgets.QCheckBox(self.widget_3)
+ self.checkBox_13.setChecked(True)
+ self.checkBox_13.setObjectName("checkBox_13")
+ self.formLayout_2.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.checkBox_13)
+ self.checkBox_14 = QtWidgets.QCheckBox(self.widget_3)
+ self.checkBox_14.setChecked(True)
+ self.checkBox_14.setObjectName("checkBox_14")
+ self.formLayout_2.setWidget(8, QtWidgets.QFormLayout.FieldRole, self.checkBox_14)
+ self.checkBox_15 = QtWidgets.QCheckBox(self.widget_3)
+ self.checkBox_15.setChecked(True)
+ self.checkBox_15.setObjectName("checkBox_15")
+ self.formLayout_2.setWidget(9, QtWidgets.QFormLayout.FieldRole, self.checkBox_15)
self.verticalLayout.addWidget(self.widget_3)
self.widget_4 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_4.setObjectName("widget_4")
- self.formLayout_4 = QtWidgets.QFormLayout(self.widget_4)
+ self.formLayout_3 = QtWidgets.QFormLayout(self.widget_4)
+ self.formLayout_3.setContentsMargins(0, 0, 0, 0)
+ self.formLayout_3.setObjectName("formLayout_3")
+ self.titleLabel5 = QtWidgets.QLabel(self.widget_4)
+ self.titleLabel5.setObjectName("titleLabel5")
+ self.formLayout_3.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel5)
+ self.checkBox_16 = QtWidgets.QCheckBox(self.widget_4)
+ self.checkBox_16.setChecked(True)
+ self.checkBox_16.setObjectName("checkBox_16")
+ self.formLayout_3.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.checkBox_16)
+ self.checkBox_17 = QtWidgets.QCheckBox(self.widget_4)
+ self.checkBox_17.setChecked(True)
+ self.checkBox_17.setObjectName("checkBox_17")
+ self.formLayout_3.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_17)
+ self.checkBox_18 = QtWidgets.QCheckBox(self.widget_4)
+ self.checkBox_18.setChecked(True)
+ self.checkBox_18.setObjectName("checkBox_18")
+ self.formLayout_3.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_18)
+ self.checkBox_19 = QtWidgets.QCheckBox(self.widget_4)
+ self.checkBox_19.setChecked(True)
+ self.checkBox_19.setObjectName("checkBox_19")
+ self.formLayout_3.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_19)
+ self.verticalLayout.addWidget(self.widget_4)
+ self.widget_5 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
+ self.widget_5.setObjectName("widget_5")
+ self.formLayout_4 = QtWidgets.QFormLayout(self.widget_5)
self.formLayout_4.setContentsMargins(0, 0, 0, 0)
self.formLayout_4.setObjectName("formLayout_4")
- self.titleLabel6 = QtWidgets.QLabel(self.widget_4)
+ self.titleLabel6 = QtWidgets.QLabel(self.widget_5)
self.titleLabel6.setObjectName("titleLabel6")
self.formLayout_4.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel6)
- self.checkBox_20 = QtWidgets.QCheckBox(self.widget_4)
+ self.checkBox_20 = QtWidgets.QCheckBox(self.widget_5)
self.checkBox_20.setObjectName("checkBox_20")
self.formLayout_4.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.checkBox_20)
- self.checkBox_21 = QtWidgets.QCheckBox(self.widget_4)
+ self.checkBox_21 = QtWidgets.QCheckBox(self.widget_5)
self.checkBox_21.setObjectName("checkBox_21")
self.formLayout_4.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_21)
- self.checkBox_22 = QtWidgets.QCheckBox(self.widget_4)
+ self.checkBox_22 = QtWidgets.QCheckBox(self.widget_5)
self.checkBox_22.setObjectName("checkBox_22")
self.formLayout_4.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_22)
- self.checkBox_23 = QtWidgets.QCheckBox(self.widget_4)
+ self.checkBox_23 = QtWidgets.QCheckBox(self.widget_5)
self.checkBox_23.setObjectName("checkBox_23")
self.formLayout_4.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_23)
- self.checkBox_24 = QtWidgets.QCheckBox(self.widget_4)
+ self.checkBox_24 = QtWidgets.QCheckBox(self.widget_5)
self.checkBox_24.setObjectName("checkBox_24")
self.formLayout_4.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.checkBox_24)
- self.right5 = QtWidgets.QLabel(self.widget_4)
+ self.right5 = QtWidgets.QLabel(self.widget_5)
self.right5.setObjectName("right5")
self.formLayout_4.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.right5)
- self.label_3 = QtWidgets.QLabel(self.widget_4)
+ self.label_3 = QtWidgets.QLabel(self.widget_5)
self.label_3.setObjectName("label_3")
self.formLayout_4.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.label_3)
- self.label_4 = QtWidgets.QLabel(self.widget_4)
+ self.label_4 = QtWidgets.QLabel(self.widget_5)
self.label_4.setObjectName("label_4")
self.formLayout_4.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.label_4)
- self.radioButton = QtWidgets.QRadioButton(self.widget_4)
+ self.radioButton = QtWidgets.QRadioButton(self.widget_5)
self.radioButton.setObjectName("radioButton")
self.formLayout_4.setWidget(8, QtWidgets.QFormLayout.FieldRole, self.radioButton)
- self.radioButton_2 = QtWidgets.QRadioButton(self.widget_4)
+ self.radioButton_2 = QtWidgets.QRadioButton(self.widget_5)
self.radioButton_2.setObjectName("radioButton_2")
self.formLayout_4.setWidget(9, QtWidgets.QFormLayout.FieldRole, self.radioButton_2)
- self.radioButton_3 = QtWidgets.QRadioButton(self.widget_4)
+ self.radioButton_3 = QtWidgets.QRadioButton(self.widget_5)
self.radioButton_3.setChecked(True)
self.radioButton_3.setObjectName("radioButton_3")
self.formLayout_4.setWidget(10, QtWidgets.QFormLayout.FieldRole, self.radioButton_3)
self.formLayout_5 = QtWidgets.QFormLayout()
self.formLayout_5.setObjectName("formLayout_5")
- self.listWidget_2 = QtWidgets.QListWidget(self.widget_4)
- self.listWidget_2.setFrameShape(QtWidgets.QFrame.NoFrame)
- self.listWidget_2.setObjectName("listWidget_2")
- self.formLayout_5.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.listWidget_2)
- self.pushButton = QtWidgets.QPushButton(self.widget_4)
+ self.listWidgetUser = QtWidgets.QListWidget(self.widget_5)
+ self.listWidgetUser.setFrameShape(QtWidgets.QFrame.NoFrame)
+ self.listWidgetUser.setObjectName("listWidgetUser")
+ self.formLayout_5.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.listWidgetUser)
+ self.pushButton = QtWidgets.QPushButton(self.widget_5)
self.pushButton.setObjectName("pushButton")
self.formLayout_5.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.pushButton)
self.formLayout_4.setLayout(11, QtWidgets.QFormLayout.FieldRole, self.formLayout_5)
- self.verticalLayout.addWidget(self.widget_4)
- self.widget_5 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
- self.widget_5.setObjectName("widget_5")
- self.formLayout_6 = QtWidgets.QFormLayout(self.widget_5)
- self.formLayout_6.setContentsMargins(0, 0, 0, 0)
- self.formLayout_6.setObjectName("formLayout_6")
- self.titleLabel7 = QtWidgets.QLabel(self.widget_5)
- self.titleLabel7.setObjectName("titleLabel7")
- self.formLayout_6.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel7)
- self.label_6 = QtWidgets.QLabel(self.widget_5)
- self.label_6.setObjectName("label_6")
- self.formLayout_6.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.label_6)
- self.pushButton_2 = QtWidgets.QPushButton(self.widget_5)
- self.pushButton_2.setObjectName("pushButton_2")
- self.formLayout_6.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.pushButton_2)
self.verticalLayout.addWidget(self.widget_5)
self.widget_6 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_6.setObjectName("widget_6")
- self.formLayout_7 = QtWidgets.QFormLayout(self.widget_6)
+ self.formLayout_6 = QtWidgets.QFormLayout(self.widget_6)
+ self.formLayout_6.setContentsMargins(0, 0, 0, 0)
+ self.formLayout_6.setObjectName("formLayout_6")
+ self.titleLabel7 = QtWidgets.QLabel(self.widget_6)
+ self.titleLabel7.setObjectName("titleLabel7")
+ self.formLayout_6.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel7)
+ self.label_6 = QtWidgets.QLabel(self.widget_6)
+ self.label_6.setObjectName("label_6")
+ self.formLayout_6.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.label_6)
+ self.pushButton_2 = QtWidgets.QPushButton(self.widget_6)
+ self.pushButton_2.setObjectName("pushButton_2")
+ self.formLayout_6.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.pushButton_2)
+ self.verticalLayout.addWidget(self.widget_6)
+ self.widget_7 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
+ self.widget_7.setObjectName("widget_7")
+ self.formLayout_7 = QtWidgets.QFormLayout(self.widget_7)
self.formLayout_7.setContentsMargins(0, 0, 0, 0)
self.formLayout_7.setObjectName("formLayout_7")
- self.titleLabel8 = QtWidgets.QLabel(self.widget_6)
+ self.titleLabel8 = QtWidgets.QLabel(self.widget_7)
self.titleLabel8.setObjectName("titleLabel8")
self.formLayout_7.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel8)
- self.checkBox_25 = QtWidgets.QCheckBox(self.widget_6)
+ self.checkBox_25 = QtWidgets.QCheckBox(self.widget_7)
self.checkBox_25.setObjectName("checkBox_25")
self.formLayout_7.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.checkBox_25)
- self.right6 = QtWidgets.QLabel(self.widget_6)
+ self.right6 = QtWidgets.QLabel(self.widget_7)
self.right6.setObjectName("right6")
self.formLayout_7.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.right6)
- self.verticalLayout.addWidget(self.widget_6)
+ self.verticalLayout.addWidget(self.widget_7)
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.horizontalLayout.addWidget(self.scrollArea)
self.retranslateUi(Setting)
+ self.listWidget.setCurrentRow(0)
QtCore.QMetaObject.connectSlotsByName(Setting)
+ Setting.setTabOrder(self.listWidget, self.scrollArea)
+ Setting.setTabOrder(self.scrollArea, self.CheckBox)
+ Setting.setTabOrder(self.CheckBox, self.checkBox)
+ Setting.setTabOrder(self.checkBox, self.checkBox_2)
+ Setting.setTabOrder(self.checkBox_2, self.checkBox_3)
+ Setting.setTabOrder(self.checkBox_3, self.checkBox_4)
+ Setting.setTabOrder(self.checkBox_4, self.checkBox_5)
+ Setting.setTabOrder(self.checkBox_5, self.checkBox_6)
+ Setting.setTabOrder(self.checkBox_6, self.checkBox_26)
+ Setting.setTabOrder(self.checkBox_26, self.checkBox_27)
+ Setting.setTabOrder(self.checkBox_27, self.checkBox_28)
+ Setting.setTabOrder(self.checkBox_28, self.checkBox_29)
+ Setting.setTabOrder(self.checkBox_29, self.right1)
+ Setting.setTabOrder(self.right1, self.right2)
+ Setting.setTabOrder(self.right2, self.right3)
+ Setting.setTabOrder(self.right3, self.comboBox)
+ Setting.setTabOrder(self.comboBox, self.checkBox_30)
+ Setting.setTabOrder(self.checkBox_30, self.checkBox_31)
+ Setting.setTabOrder(self.checkBox_31, self.pushButton_5)
+ Setting.setTabOrder(self.pushButton_5, self.pushButton_4)
+ Setting.setTabOrder(self.pushButton_4, self.CheckBox_2)
+ Setting.setTabOrder(self.CheckBox_2, self.checkBox_7)
+ Setting.setTabOrder(self.checkBox_7, self.checkBox_8)
+ Setting.setTabOrder(self.checkBox_8, self.checkBox_9)
+ Setting.setTabOrder(self.checkBox_9, self.checkBox_10)
+ Setting.setTabOrder(self.checkBox_10, self.checkBox_11)
+ Setting.setTabOrder(self.checkBox_11, self.checkBox_12)
+ Setting.setTabOrder(self.checkBox_12, self.checkBox_13)
+ Setting.setTabOrder(self.checkBox_13, self.checkBox_14)
+ Setting.setTabOrder(self.checkBox_14, self.checkBox_15)
+ Setting.setTabOrder(self.checkBox_15, self.checkBox_16)
+ Setting.setTabOrder(self.checkBox_16, self.checkBox_17)
+ Setting.setTabOrder(self.checkBox_17, self.checkBox_18)
+ Setting.setTabOrder(self.checkBox_18, self.checkBox_19)
+ Setting.setTabOrder(self.checkBox_19, self.checkBox_20)
+ Setting.setTabOrder(self.checkBox_20, self.checkBox_21)
+ Setting.setTabOrder(self.checkBox_21, self.checkBox_22)
+ Setting.setTabOrder(self.checkBox_22, self.checkBox_23)
+ Setting.setTabOrder(self.checkBox_23, self.checkBox_24)
+ Setting.setTabOrder(self.checkBox_24, self.radioButton)
+ Setting.setTabOrder(self.radioButton, self.radioButton_2)
+ Setting.setTabOrder(self.radioButton_2, self.radioButton_3)
+ Setting.setTabOrder(self.radioButton_3, self.listWidgetUser)
+ Setting.setTabOrder(self.listWidgetUser, self.pushButton)
+ Setting.setTabOrder(self.pushButton, self.pushButton_2)
+ Setting.setTabOrder(self.pushButton_2, self.checkBox_25)
def retranslateUi(self, Setting):
_translate = QtCore.QCoreApplication.translate
diff --git a/仿QQ设置面板/Window.py b/仿QQ设置面板/Window.py
index f4f6b7f..0b48bcc 100644
--- a/仿QQ设置面板/Window.py
+++ b/仿QQ设置面板/Window.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget
from 仿QQ设置面板.SettingUi import Ui_Setting
@@ -23,14 +22,42 @@ class Window(QWidget, Ui_Setting):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
self.setupUi(self)
- self.resize(877, 637)
+ self.resize(700, 435)
+ self._blockSignals = False
+
+ # 绑定滚动条和左侧item事件
+ self.scrollArea.verticalScrollBar().valueChanged.connect(self.onValueChanged)
+ self.listWidget.itemClicked.connect(self.onItemClicked)
+
+ def onValueChanged(self, value):
+ """滚动条"""
+ if self._blockSignals:
+ # 防止item点击时改变滚动条会触发这里
+ return
+ for i in range(8): # 因为这里右侧有8个widget
+ widget = getattr(self, 'widget_%d' % i, None)
+ if widget and not widget.visibleRegion().isEmpty(): # widget不为空且在可视范围内
+ self.listWidget.setCurrentRow(i) # 设置item的选中
+ return
+
+ def onItemClicked(self, item):
+ """左侧item"""
+ row = self.listWidget.row(item) # 获取点击的item的索引
+ # 由于右侧的widget是按照命名widget_0 widget_1这样比较规范的方法,可以通过getattr找到
+ widget = getattr(self, 'widget_%d' % row, None)
+ if not widget:
+ return
+ # 定位右侧位置并滚动
+ self._blockSignals = True
+ self.scrollArea.verticalScrollBar().setSliderPosition(widget.pos().y())
+ self._blockSignals = False
if __name__ == '__main__':
import sys
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
- app.setStyleSheet(open("style.qss","rb").read().decode("utf-8"))
+ app.setStyleSheet(open("style.qss", "rb").read().decode("utf-8"))
w = Window()
w.show()
sys.exit(app.exec_())
diff --git a/仿QQ设置面板/setting.ui b/仿QQ设置面板/setting.ui
index 8e70e29..fa558e4 100644
--- a/仿QQ设置面板/setting.ui
+++ b/仿QQ设置面板/setting.ui
@@ -6,8 +6,8 @@
0
0
- 565
- 535
+ 498
+ 498
@@ -34,6 +34,15 @@
QFrame::NoFrame
+
+ Qt::ScrollBarAlwaysOff
+
+
+ Qt::ScrollBarAlwaysOff
+
+
+ 0
+
-
登录
@@ -116,9 +125,9 @@
0
- -60
- 613
- 1521
+ -810
+ 460
+ 1308
@@ -138,7 +147,7 @@
20
-
-
+
0
@@ -218,7 +227,7 @@
-
-
+
0
@@ -309,7 +318,7 @@
-
-
+
0
@@ -373,6 +382,19 @@
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
-
@@ -412,13 +434,26 @@
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
-
-
+
0
@@ -537,7 +572,7 @@
-
-
+
0
@@ -602,7 +637,7 @@
-
-
+
0
@@ -706,7 +741,7 @@
-
-
-
+
QFrame::NoFrame
@@ -725,7 +760,7 @@
-
-
+
0
@@ -764,7 +799,7 @@
-
-
+
0
@@ -808,6 +843,55 @@
+
+ listWidget
+ scrollArea
+ CheckBox
+ checkBox
+ checkBox_2
+ checkBox_3
+ checkBox_4
+ checkBox_5
+ checkBox_6
+ checkBox_26
+ checkBox_27
+ checkBox_28
+ checkBox_29
+ right1
+ right2
+ right3
+ comboBox
+ checkBox_30
+ checkBox_31
+ pushButton_5
+ pushButton_4
+ CheckBox_2
+ checkBox_7
+ checkBox_8
+ checkBox_9
+ checkBox_10
+ checkBox_11
+ checkBox_12
+ checkBox_13
+ checkBox_14
+ checkBox_15
+ checkBox_16
+ checkBox_17
+ checkBox_18
+ checkBox_19
+ checkBox_20
+ checkBox_21
+ checkBox_22
+ checkBox_23
+ checkBox_24
+ radioButton
+ radioButton_2
+ radioButton_3
+ listWidgetUser
+ pushButton
+ pushButton_2
+ checkBox_25
+
diff --git a/仿QQ设置面板/style.qss b/仿QQ设置面板/style.qss
index 59537db..fb7d57b 100644
--- a/仿QQ设置面板/style.qss
+++ b/仿QQ设置面板/style.qss
@@ -22,5 +22,56 @@
#titleLabel1,#titleLabel2,#titleLabel3,#titleLabel4,#titleLabel5,#titleLabel6,#titleLabel7,#titleLabel8 {
min-width: 75px;
max-width: 75px;
- background-color: red;
+}
+
+#right1,#right2,#right3,#right4,#right5,#right6 {
+ margin-left: 25px;
+ color: rgb(128, 128, 128);
+}
+
+/*所有按钮*/
+QPushButton {
+ max-width: 80px;
+ max-height: 24px;
+ min-height: 24px;
+ border-radius: 3px;
+ background-color: rgb(244, 244, 244);
+ border: 1px solid rgb(167, 167, 167);
+}
+QPushButton:hover {
+ background-color: rgb(190, 231, 253);
+}
+QPushButton:pressed {
+ background-color: rgb(244, 244, 244);
+}
+
+QComboBox {
+ max-width: 80px;
+ max-height: 20px;
+ min-height: 20px;
+}
+
+QComboBox {
+ border: 1px solid rgb(167, 167, 167);
+ border-radius: 3px;
+}
+
+#listWidgetUser {
+ min-width: 290px;
+ max-width: 290px;
+ max-height: 120px;
+ min-height: 120px;
+ border-radius: 2px;
+ border: 1px solid rgb(227, 236, 242);
+ background-color: rgb(244, 250, 253);
+}
+
+QScrollBar::vertical {
+ background: rgb(178, 178, 178);
+ border: -5px solid grey;
+ margin: 0px 0px 0px 0px;
+ width: 10px;
+}
+QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
+ background: white;
}
\ No newline at end of file