├── .gitignore ├── LICENSE ├── README.md ├── SlimScrollBar.pro ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── mytextedit.cpp ├── mytextedit.h ├── slim_scroll_bar ├── slimscrollbar.cpp ├── slimscrollbar.h ├── slimscrollbarpopup.cpp └── slimscrollbarpopup.h └── 果冻条.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 纤细的滚动条——果冻条 2 | === 3 | 4 | 一个可以像弓弦一样拉出来,并且来回弹动的普通滚动条。 5 | 6 | 思路为此,但发现实际效果更像条状果冻,并且略有谐音, 7 | 8 | 故,称之为——“果冻条”! 9 | 10 | ![果冻条](果冻条.gif) -------------------------------------------------------------------------------- /SlimScrollBar.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | 5 | CONFIG += c++11 6 | 7 | # The following define makes your compiler emit warnings if you use 8 | # any Qt feature that has been marked deprecated (the exact warnings 9 | # depend on your compiler). Please consult the documentation of the 10 | # deprecated API in order to know how to port your code away from it. 11 | DEFINES += QT_DEPRECATED_WARNINGS 12 | 13 | # You can also make your code fail to compile if it uses deprecated APIs. 14 | # In order to do so, uncomment the following line. 15 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 16 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 17 | 18 | INCLUDEPATH += slim_scroll_bar 19 | 20 | SOURCES += \ 21 | main.cpp \ 22 | mainwindow.cpp \ 23 | mytextedit.cpp \ 24 | slim_scroll_bar/slimscrollbar.cpp \ 25 | slim_scroll_bar/slimscrollbarpopup.cpp 26 | 27 | HEADERS += \ 28 | mainwindow.h \ 29 | mytextedit.h \ 30 | slim_scroll_bar/slimscrollbar.h \ 31 | slim_scroll_bar/slimscrollbarpopup.h 32 | 33 | FORMS += \ 34 | mainwindow.ui 35 | 36 | # Default rules for deployment. 37 | qnx: target.path = /tmp/$${TARGET}/bin 38 | else: unix:!android: target.path = /opt/$${TARGET}/bin 39 | !isEmpty(target.path): INSTALLS += target 40 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | MainWindow w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | 4 | MainWindow::MainWindow(QWidget *parent) 5 | : QMainWindow(parent) 6 | , ui(new Ui::MainWindow) 7 | { 8 | ui->setupUi(this); 9 | } 10 | 11 | MainWindow::~MainWindow() 12 | { 13 | delete ui; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include "slimscrollbar.h" 6 | 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class MainWindow; } 9 | QT_END_NAMESPACE 10 | 11 | class MainWindow : public QMainWindow 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | MainWindow(QWidget *parent = nullptr); 17 | ~MainWindow(); 18 | 19 | private: 20 | Ui::MainWindow *ui; 21 | }; 22 | #endif // MAINWINDOW_H 23 | -------------------------------------------------------------------------------- /mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 272 10 | 451 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | QMainWindow { 18 | background: white; 19 | } 20 | 21 | 22 | 23 | 24 | 25 | 26 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> 27 | <html><head><meta name="qrichtext" content="1" /><style type="text/css"> 28 | p, li { white-space: pre-wrap; } 29 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> 30 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;</span></p> 31 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;</span></p> 32 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">p, li { white-space: pre-wrap; }</span></p> 33 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;</span></p> 34 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;</span></p> 35 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;</span></p> 36 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">p, li { white-space: pre-wrap; }</span></p> 37 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;</span></p> 38 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;</span></p> 39 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;</span></p> 40 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">p, li { white-space: pre-wrap; }</span></p> 41 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;</span></p> 42 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;</span></p> 43 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;</span></p> 44 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">p, li { white-space: pre-wrap; }</span></p> 45 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;</span></p> 46 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;</span></p> 47 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;</span></p> 48 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">p, li { white-space: pre-wrap; }</span></p> 49 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;</span></p> 50 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;</span></p> 51 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;</span></p> 52 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">p, li { white-space: pre-wrap; }</span></p> 53 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;</span></p> 54 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;</span></p> 55 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;</span></p> 56 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">p, li { white-space: pre-wrap; }</span></p> 57 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;</span></p> 58 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;</span></p> 59 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;</span></p> 60 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">p, li { white-space: pre-wrap; }</span></p> 61 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;</span></p> 62 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;</span></p> 63 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;</span></p> 64 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">p, li { white-space: pre-wrap; }</span></p> 65 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;</span></p> 66 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;</span></p> 67 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;</span></p> 68 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">p, li { white-space: pre-wrap; }</span></p> 69 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;</span></p> 70 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;</span></p> 71 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;</span></p> 72 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">p, li { white-space: pre-wrap; }</span></p> 73 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;</span></p> 74 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;</span></p> 75 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;</span></p> 76 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">p, li { white-space: pre-wrap; }</span></p> 77 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;</span></p> 78 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;</span></p> 79 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;</span></p> 80 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">p, li { white-space: pre-wrap; }</span></p> 81 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;</span></p> 82 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;</span></p> 83 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;</span></p> 84 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">p, li { white-space: pre-wrap; }</span></p> 85 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;</span></p> 86 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;</span></p> 87 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;</span></p> 88 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">p, li { white-space: pre-wrap; }</span></p> 89 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;</span></p> 90 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun';">&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</span></p></body></html> 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 0 100 | 0 101 | 272 102 | 23 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | MyTextEdit 111 | QTextEdit 112 |
mytextedit.h
113 |
114 |
115 | 116 | 117 |
118 | -------------------------------------------------------------------------------- /mytextedit.cpp: -------------------------------------------------------------------------------- 1 | #include "mytextedit.h" 2 | 3 | MyTextEdit::MyTextEdit(QWidget *parent) : QTextEdit(parent) 4 | { 5 | slim = new SlimScrollBar(this->parentWidget()); 6 | setVerticalScrollBar(slim); 7 | } 8 | 9 | void MyTextEdit::paintEvent(QPaintEvent *e) 10 | { 11 | QTextEdit::paintEvent(e); 12 | } 13 | -------------------------------------------------------------------------------- /mytextedit.h: -------------------------------------------------------------------------------- 1 | #ifndef MYTEXTEDIT_H 2 | #define MYTEXTEDIT_H 3 | 4 | #include 5 | #include 6 | #include "slimscrollbar.h" 7 | 8 | class MyTextEdit : public QTextEdit 9 | { 10 | public: 11 | MyTextEdit(QWidget* parent = nullptr); 12 | 13 | protected: 14 | void paintEvent(QPaintEvent *e) override; 15 | 16 | private: 17 | SlimScrollBar* slim; 18 | }; 19 | 20 | #endif // MYTEXTEDIT_H 21 | -------------------------------------------------------------------------------- /slim_scroll_bar/slimscrollbar.cpp: -------------------------------------------------------------------------------- 1 | #include "slimscrollbar.h" 2 | 3 | SlimScrollBar::SlimScrollBar(QWidget *parent) 4 | : QScrollBar(parent), 5 | elastic_coefficient(1.2), jitter_duration(300), 6 | water_press_duration(800), water_release_duration(400), water_finish_duration(300) 7 | { 8 | /*popup = new SlimScrollBarPopup(nullptr); 9 | popup->pixmap = &pixmap; 10 | popup->show(); 11 | popup->setGeometry(-2, -2, 0, 0);*/ 12 | 13 | setStyleSheet("\ 14 | QScrollBar:vertical\ 15 | {\ 16 | width:12px;\ 17 | background:rgba(0,0,0,0%);\ 18 | margin:0px,0px,0px,0px;\ 19 | /*留出9px给上面和下面的箭头*/\ 20 | padding-top:0px;\ 21 | padding-bottom:0px;\ 22 | }\ 23 | QScrollBar::handle:vertical\ 24 | {\ 25 | width:12px;\ 26 | background:rgba(0,0,0,0%);\ 27 | /*滚动条两端变成椭圆*/\ 28 | border-radius:0px;\ 29 | min-height:20;\ 30 | }\ 31 | QScrollBar::handle:vertical:hover\ 32 | {\ 33 | width:8px;\ 34 | /*鼠标放到滚动条上的时候,颜色变深*/\ 35 | background:rgba(0,0,0,0%);\ 36 | border-radius:0px;\ 37 | min-height:20;\ 38 | }\ 39 | /*这个应该是设置下箭头的,3.png就是箭头*/\ 40 | QScrollBar::add-line:vertical\ 41 | {\ 42 | height:0px;width:0px;\ 43 | border-image:url(:/images/a/3.png);\ 44 | subcontrol-position:bottom;\ 45 | }\ 46 | /*设置上箭头*/\ 47 | QScrollBar::sub-line:vertical\ 48 | {\ 49 | height:0px;width:0px;\ 50 | border-image:url(:/images/a/1.png);\ 51 | subcontrol-position:top;\ 52 | }\ 53 | /*当鼠标放到下箭头上的时候*/\ 54 | QScrollBar::add-line:vertical:hover\ 55 | {\ 56 | height:0px;width:0px;\ 57 | border-image:url(:/images/a/4.png);\ 58 | subcontrol-position:bottom;\ 59 | }\ 60 | /*当鼠标放到下箭头上的时候*/\ 61 | QScrollBar::sub-line:vertical:hover\ 62 | {\ 63 | height:0px;width:0px;\ 64 | border-image:url(:/images/a/2.png);\ 65 | subcontrol-position:top;\ 66 | }\ 67 | /*当滚动条滚动的时候,上面的部分和下面的部分*/\ 68 | QScrollBar::add-page:vertical,QScrollBar::sub-page:vertical\ 69 | {\ 70 | background:rgba(0,0,0,0%);\ 71 | border-radius:0px;\ 72 | }"); 73 | 74 | event_timer = new QTimer(this); 75 | event_timer->setInterval(16); 76 | connect(event_timer, SIGNAL(timeout()), this, SLOT(eventTimer())); 77 | } 78 | 79 | void SlimScrollBar::enterEvent(QEvent *e) 80 | { 81 | DEB_EVENT << "enterEvent" << e; 82 | QScrollBar::enterEvent(e); 83 | 84 | activeTimer(); 85 | 86 | hovering = true; 87 | } 88 | 89 | void SlimScrollBar::leaveEvent(QEvent *e) 90 | { 91 | DEB_EVENT << "leaveEvent" << e; 92 | QScrollBar::leaveEvent(e); 93 | 94 | hovering = false; 95 | } 96 | 97 | void SlimScrollBar::mousePressEvent(QMouseEvent *e) 98 | { 99 | DEB_EVENT << "mousePressEvent" << e; 100 | QScrollBar::mousePressEvent(e); 101 | 102 | activeTimer(); 103 | if (e->button() == Qt::LeftButton) 104 | { 105 | jitters.clear(); 106 | pressing = true; 107 | mouse_pos = press_pos = e->pos(); 108 | setOffsetPoss(); 109 | } 110 | } 111 | 112 | void SlimScrollBar::mouseMoveEvent(QMouseEvent *e) 113 | { 114 | DEB_EVENT << "mouseMoveEvent" << e; 115 | QScrollBar::mouseMoveEvent(e); 116 | 117 | if(pressing) 118 | { 119 | mouse_pos = e->pos(); 120 | setOffsetPoss(); 121 | 122 | // 判断拖拽的位置,调整可视区域大小 123 | // 已经显示弹窗,则应该实时调整 124 | // 如果没有,那么当开始拖拽的时候,就应该开始调整 125 | if (popuping || qAbs(e->pos().x() - press_pos.x()) >= width()) 126 | { 127 | // 拖动,重新设置大小 128 | calcPixmapSize(); 129 | 130 | if (!popuping) 131 | { 132 | startPopup(); 133 | } 134 | } 135 | } 136 | } 137 | 138 | void SlimScrollBar::mouseReleaseEvent(QMouseEvent *e) 139 | { 140 | DEB_EVENT << "mouseReleaseEvent" << e; 141 | QScrollBar::mouseReleaseEvent(e); 142 | 143 | if (pressing && e->button() == Qt::LeftButton) 144 | { 145 | setJitter(); 146 | } 147 | } 148 | 149 | void SlimScrollBar::wheelEvent(QWheelEvent *e) 150 | { 151 | DEB_EVENT << "wheelEvent" << e; 152 | QScrollBar::wheelEvent(e); 153 | } 154 | 155 | void SlimScrollBar::paintEvent(QPaintEvent *e) 156 | { 157 | // 这里是透明度,必须得绘制(不然是纯黑色) 158 | // QScrollBar::paintEvent(e); 159 | if (!enabling) 160 | return ; 161 | 162 | // TODO: 判断需不需要重绘 163 | 164 | // 绘制到pixmap 165 | paintPixmap(); 166 | 167 | if (!popuping) // 如果没有显示弹窗,绘制到自己 168 | { 169 | QPainter painter(this); 170 | painter.drawPixmap(QRect(0,0,width(),height()), pixmap, QRect(pixmap.width()-width(), 0, width(), height())); 171 | } 172 | else // 绘制到弹窗 173 | { 174 | repaintPopup(); 175 | } 176 | } 177 | 178 | /** 179 | * 开始加载、调整大小的时候都会触发 180 | * - 0 范围改变 181 | * - 1 方向改变 182 | * - 2 步长改变 183 | * - 3 进度改变(最容易触发) 184 | */ 185 | void SlimScrollBar::sliderChange(QAbstractSlider::SliderChange change) 186 | { 187 | QScrollBar::sliderChange(change); 188 | if (change == 0) 189 | emit rangeChanged(minimum(), maximum()); // 手动调用改变事件,用来触发 190 | if (change != 3) 191 | DEB_EVENT << "sliderChange" << change << "(" << minimum() << maximum() << ")" << pageStep(); 192 | else 193 | DEB_EVENT << "sliderChange" << change << "(" << minimum() << maximum() << ")" << sliderPosition(); 194 | } 195 | 196 | void SlimScrollBar::contextMenuEvent(QContextMenuEvent *e) 197 | { 198 | DEB_EVENT << "contextMenuEvent" << e; 199 | QScrollBar::contextMenuEvent(e); 200 | } 201 | 202 | void SlimScrollBar::hideEvent(QHideEvent *e) 203 | { 204 | DEB_EVENT << "hideEvent" << e; 205 | QScrollBar::hideEvent(e); 206 | } 207 | 208 | void SlimScrollBar::resizeEvent(QResizeEvent *e) 209 | { 210 | DEB_EVENT << "resizeEvent" << e; 211 | QScrollBar::resizeEvent(e); 212 | 213 | // 重新设置滚动条图片的大小 214 | pixmap = QPixmap(e->size()); 215 | // 应该会自动update吧 216 | // update(); 217 | } 218 | 219 | /** 220 | * 绘制自身控件至pixmap;自己绘制进度条内的部分 221 | * 如果大小改变,则调整pixmap的大小 222 | */ 223 | void SlimScrollBar::paintPixmap() 224 | { 225 | pixmap.fill(Qt::transparent); 226 | QPainter painter(&pixmap); 227 | painter.setRenderHint(QPainter::SmoothPixmapTransform, true); 228 | painter.setRenderHint(QPainter::Antialiasing, true); 229 | 230 | if (!popuping) // 直接画矩形 231 | { 232 | // 绘制背景 233 | QRect bg_rect(0,0,width(),height()); 234 | painter.fillRect(bg_rect,bg_normal_color); 235 | if (hover_prop) 236 | { 237 | QColor c = bg_hover_color; 238 | c.setAlpha(c.alpha() * hover_prop / 100); 239 | painter.fillRect(bg_rect, c); 240 | } 241 | if (press_prop) 242 | { 243 | QColor c = bg_press_color; 244 | c.setAlpha(c.alpha() * press_prop / 100); 245 | painter.fillRect(bg_rect, c); 246 | } 247 | 248 | // 绘制前景 249 | int step = this->pageStep(); 250 | int range = maximum() - minimum() + step; 251 | int height = qMax(this->height() * step / range, 16); 252 | int top = this->height() * (sliderPosition()+minimum()) / range; 253 | 254 | int pen_w = width(); 255 | if (!round_cap) // 需要微调大小 256 | { 257 | top += pen_w / 2; 258 | height -= pen_w; 259 | } 260 | 261 | // QRect fg_rect(0, top, width(), height); 262 | // painter.fillRect(fg_rect, fg_normal_color); 263 | QPainterPath bg_path; 264 | bg_path.moveTo(pen_w/2, top); 265 | bg_path.lineTo(pen_w/2, top + height); 266 | painter.setPen(getPen(fg_normal_color, pen_w)); 267 | painter.drawPath(bg_path); 268 | if (hover_prop) 269 | { 270 | QColor c = fg_hover_color; 271 | c.setAlpha(c.alpha() * hover_prop / 100); 272 | // painter.fillRect(fg_rect, c); 273 | painter.setPen(getPen(fg_hover_color, pen_w)); 274 | painter.drawPath(bg_path); 275 | } 276 | if (press_prop) 277 | { 278 | QColor c = fg_press_color; 279 | c.setAlpha(c.alpha() * press_prop / 100); 280 | // painter.fillRect(fg_rect, c); 281 | painter.setPen(getPen(fg_press_color, pen_w)); 282 | painter.drawPath(bg_path); 283 | } 284 | } 285 | else 286 | { 287 | QPainterPath bg_path; 288 | QPainterPath fg_path; 289 | 290 | // 获取点 291 | QPoint offset(popup_offset + QPoint(width()/2, 0)); 292 | QPoint top_p(0, 0); 293 | QPoint bulge(anchor_pos); 294 | QPoint btm_p(0, height()); 295 | top_p += offset; 296 | bulge += offset; 297 | btm_p += offset; 298 | 299 | // 绘制背景 300 | bg_path.moveTo(top_p); 301 | bg_path.cubicTo(top_p, bulge, btm_p); 302 | bg_path.lineTo(btm_p); 303 | 304 | int pen_w = width(); 305 | pen_w -= quick_sqrt(qAbs(anchor_pos.x())); 306 | pen_w = qMax(1, pen_w); 307 | painter.setPen(getPen(bg_normal_color, pen_w)); 308 | painter.drawPath(bg_path); 309 | if (hover_prop) 310 | { 311 | QColor c = bg_hover_color; 312 | c.setAlpha(c.alpha() * hover_prop / 100); 313 | painter.setPen(getPen(c, pen_w)); 314 | painter.drawPath(bg_path); 315 | } 316 | if (press_prop) 317 | { 318 | QColor c = bg_press_color; 319 | c.setAlpha(c.alpha() * press_prop / 100); 320 | painter.setPen(getPen(c, pen_w)); 321 | painter.drawPath(bg_path); 322 | } 323 | 324 | // 绘制前景 325 | int step = this->pageStep(); 326 | int range = maximum() - minimum() + step; 327 | int height = qMax(this->height() * step / range, 16); 328 | int top = this->height() * (sliderPosition()+minimum()) / range; 329 | 330 | fg_path.addRect(0, top, pixmap.width(), height); 331 | painter.setClipPath(fg_path, Qt::IntersectClip); 332 | painter.setPen(getPen(fg_normal_color, width())); 333 | painter.drawPath(bg_path); 334 | if (hover_prop) 335 | { 336 | QColor c = fg_hover_color; 337 | c.setAlpha(c.alpha() * hover_prop / 100); 338 | painter.setPen(getPen(c, width())); 339 | painter.drawPath(bg_path); 340 | } 341 | if (press_prop) 342 | { 343 | QColor c = fg_press_color; 344 | c.setAlpha(c.alpha() * press_prop / 100); 345 | painter.setPen(getPen(c, width())); 346 | painter.drawPath(bg_path); 347 | } 348 | } 349 | } 350 | 351 | void SlimScrollBar::activeTimer() 352 | { 353 | if (!event_timer->isActive()) 354 | event_timer->start(); 355 | } 356 | 357 | void SlimScrollBar::setOffsetPoss() 358 | { 359 | int x = mouse_pos.x() - width()/2; 360 | const int maxi = width() * 8; 361 | if (x < -maxi) 362 | x = -maxi; 363 | else if (x > maxi) 364 | x = maxi; 365 | target_pos.setX(x); 366 | 367 | /*if (mouse_pos.y() <= 0) 368 | target_pos.setY(mouse_pos.y()); 369 | else if (mouse_pos.y() > height()) 370 | target_pos.setY(mouse_pos.y() - height()); 371 | else 372 | target_pos.setY(0);*/ 373 | target_pos.setY(mouse_pos.y()); 374 | } 375 | 376 | /** 377 | * 实时刷新界面 378 | */ 379 | void SlimScrollBar::eventTimer() 380 | { 381 | // 判断比例 382 | if (hovering) 383 | { 384 | if (hover_prop < 100) 385 | { 386 | hover_prop += 10; 387 | if (hover_prop >= 100) // 结束 388 | { 389 | hover_prop = 100; 390 | } 391 | } 392 | } 393 | else 394 | { 395 | if (hover_prop > 0) 396 | { 397 | hover_prop -= 10; 398 | if (hover_prop <= 0) // 结束 399 | { 400 | hover_prop = 0; 401 | } 402 | } 403 | } 404 | 405 | if (pressing) 406 | { 407 | if (press_prop < 100) 408 | { 409 | press_prop += 10; 410 | if (press_prop >= 100) // 结束 411 | { 412 | press_prop = 100; 413 | } 414 | } 415 | } 416 | else 417 | { 418 | if (press_prop > 0) 419 | { 420 | press_prop -= 10; 421 | if (press_prop <= 0) // 结束 422 | { 423 | press_prop = 0; 424 | } 425 | } 426 | } 427 | 428 | // 锚点移动 429 | if (jitters.size() > 0) 430 | { 431 | Jitter cur = jitters.first(); 432 | Jitter aim = jitters.at(1); 433 | int del = static_cast(getTimestamp()-cur.timestamp); 434 | int dur = static_cast(aim.timestamp - cur.timestamp); 435 | if (del > dur) 436 | del = dur; 437 | anchor_pos = effect_pos = cur.point + (aim.point-cur.point)*del/dur; 438 | 439 | if (del >= dur) 440 | jitters.removeFirst(); 441 | 442 | // 抖动结束 443 | if (jitters.size() == 1) 444 | { 445 | jitters.clear(); 446 | pressing = false; 447 | anchor_pos = effect_pos = target_pos; 448 | } 449 | } 450 | else if (anchor_pos != target_pos) 451 | { 452 | // QPoint sqrt_pos(quick_sqrt(target_pos.x()), quick_sqrt(target_pos.y())); // 开方再开方 453 | int delta_x = anchor_pos.x() - target_pos.x(); 454 | int delta_y = anchor_pos.y() - target_pos.y(); 455 | 456 | // 锚点靠近目标点 457 | anchor_pos.setX( anchor_pos.x() - quick_sqrt(delta_x) ); 458 | anchor_pos.setY( anchor_pos.y() - quick_sqrt(delta_y) ); 459 | 460 | // 偏差点是锚点 开方 461 | effect_pos.setX( quick_sqrt(static_cast(anchor_pos.x())) ); 462 | effect_pos.setY( quick_sqrt(static_cast(anchor_pos.y())) ); 463 | } 464 | 465 | // 更新图片 466 | if (popuping) 467 | { 468 | calcPixmapSize(); 469 | } 470 | 471 | // 自动暂停 472 | if(!hovering && !pressing && hover_prop == 0 && press_prop == 0 && effect_pos.x() == 0 && !jitters.size() && !waters.size()) 473 | { 474 | event_timer->stop(); 475 | if (popuping) 476 | { 477 | popuping = false; 478 | popup->setGeometry(-2, -2, 0, 0); 479 | // 删除popup 480 | popup->deleteLater(); 481 | popup = nullptr; 482 | } 483 | } 484 | 485 | update(); 486 | } 487 | 488 | void SlimScrollBar::enable() 489 | { 490 | enabling = true; 491 | } 492 | 493 | void SlimScrollBar::disable() 494 | { 495 | enabling = false; 496 | } 497 | 498 | void SlimScrollBar::setBgColors(QColor normal, QColor hover, QColor press) 499 | { 500 | bg_normal_color = normal; 501 | bg_hover_color = hover; 502 | bg_press_color = press; 503 | } 504 | 505 | void SlimScrollBar::setFgColors(QColor normal, QColor hover, QColor press) 506 | { 507 | fg_normal_color = normal; 508 | fg_hover_color = hover; 509 | fg_press_color = press; 510 | } 511 | 512 | void SlimScrollBar::setRoundCap(bool round) 513 | { 514 | round_cap = round; 515 | } 516 | 517 | /** 518 | * 速度极快的开方算法,效率未知,原理未知 519 | * @param X 待开方的数字 520 | * @return 平方根 521 | */ 522 | int SlimScrollBar::quick_sqrt(long X) const 523 | { 524 | bool fu = false; 525 | if (X < 0) 526 | { 527 | fu = true; 528 | X = -X; 529 | } 530 | #if !defined(Q_OS_WIN) 531 | X = qSqrt(X); 532 | return fu ? -X : X; 533 | #endif 534 | unsigned long M = static_cast(X); 535 | unsigned int N, i; 536 | unsigned long tmp, ttp; // 结果、循环计数 537 | if (M == 0) // 被开方数,开方结果也为0 538 | return 0; 539 | N = 0; 540 | tmp = (M >> 30); // 获取最高位:B[m-1] 541 | M <<= 2; 542 | if (tmp > 1) // 最高位为1 543 | { 544 | N ++; // 结果当前位为1,否则为默认的0 545 | tmp -= N; 546 | } 547 | for (i = 15; i > 0; i--) // 求剩余的15位 548 | { 549 | N <<= 1; // 左移一位 550 | tmp <<= 2; 551 | tmp += (M >> 30); // 假设 552 | ttp = N; 553 | ttp = (ttp << 1) + 1; 554 | M <<= 2; 555 | if (tmp >= ttp) // 假设成立 556 | { 557 | tmp -= ttp; 558 | N ++; 559 | } 560 | } 561 | return (fu ? -1 : 1) * static_cast(N); // 不知道为什么计算出来的结果是反过来的 562 | } 563 | 564 | void SlimScrollBar::calcPixmapSize() 565 | { 566 | if (!popup) 567 | { 568 | pixmap = QPixmap(width(), height()); 569 | popup_offset = QPoint(0, 0); 570 | return ; 571 | } 572 | 573 | int leftest = qMin(qMin(anchor_pos.x(), 0), effect_pos.x()); 574 | int rightest = qMax(qMax(anchor_pos.x(), width()), effect_pos.x()+width()); 575 | int wi = rightest - leftest; 576 | int topest = qMin(qMin(anchor_pos.y(), 0), effect_pos.y()); 577 | int bottomest = qMax(qMax(anchor_pos.y(), height()), effect_pos.y()+height()); 578 | int he = bottomest - topest; 579 | pixmap = QPixmap(QSize(wi, he)); 580 | popup_offset.setX(0-leftest); 581 | popup_offset.setY(0-topest); 582 | } 583 | 584 | /** 585 | * 切换至浮窗界面 586 | * 初始化所有数据 587 | */ 588 | void SlimScrollBar::startPopup() 589 | { 590 | popuping = true; 591 | if (!popup) 592 | { 593 | popup = new SlimScrollBarPopup(nullptr); 594 | popup->scrollbar_pixmap = pixmap; 595 | popup->show(); 596 | } 597 | 598 | paintPixmap(); 599 | repaintPopup(); 600 | } 601 | 602 | /** 603 | * 自己更新界面,重绘弹窗 604 | */ 605 | void SlimScrollBar::repaintPopup() 606 | { 607 | // 设置大小 608 | popup->setGeometry(QRect(mapToGlobal(pos())-popup_offset, pixmap.size())); 609 | // 设置绘制位置 610 | popup->offset = popup_offset; 611 | popup->scrollbar_pixmap = pixmap; 612 | // 绘制图片 613 | popup->update(); 614 | } 615 | 616 | /** 617 | * 鼠标松开的时候,计算所有抖动效果的路径和事件 618 | * 在每次重绘界面的时候,依次遍历所有的路径 619 | */ 620 | void SlimScrollBar::setJitter() 621 | { 622 | pressing = false; 623 | jitters.clear(); 624 | QPoint center_pos(0, anchor_pos.y()); 625 | if (center_pos.y() < 0) 626 | center_pos.setY(0); 627 | else if (center_pos.y() > height()) 628 | center_pos.setY(height()); 629 | int full_manh = qAbs(anchor_pos.x()); 630 | if (full_manh > width() * 3) 631 | { 632 | pressing = true; // 动画消失的时候再关闭 633 | QPoint jitter_pos(anchor_pos); 634 | full_manh = (jitter_pos-center_pos).manhattanLength(); 635 | int manh = full_manh; 636 | int duration = jitter_duration; 637 | qint64 timestamp = getTimestamp(); 638 | while (manh > elastic_coefficient) 639 | { 640 | jitters << Jitter(jitter_pos, timestamp); 641 | jitter_pos = center_pos - (jitter_pos - center_pos) / elastic_coefficient; 642 | duration = jitter_duration * manh / full_manh; 643 | timestamp += duration; 644 | manh = static_cast(manh / elastic_coefficient); 645 | } 646 | jitters << Jitter(center_pos, timestamp); 647 | anchor_pos = mouse_pos = center_pos; 648 | } 649 | target_pos = QPoint(0, center_pos.y()); 650 | } 651 | 652 | /** 653 | * 获取现行时间戳,13位,精确到毫秒 654 | * @return 时间戳 655 | */ 656 | qint64 SlimScrollBar::getTimestamp() 657 | { 658 | return QDateTime::currentDateTime().toMSecsSinceEpoch(); 659 | } 660 | 661 | QPen SlimScrollBar::getPen(QColor color, int width) 662 | { 663 | return QPen(color, width, Qt::SolidLine, round_cap ? Qt::RoundCap : Qt::SquareCap); 664 | } 665 | -------------------------------------------------------------------------------- /slim_scroll_bar/slimscrollbar.h: -------------------------------------------------------------------------------- 1 | #ifndef SLIMSCROLLBAR_H 2 | #define SLIMSCROLLBAR_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "slimscrollbarpopup.h" 15 | 16 | #define DEB_EVENT if (0) qDebug() 17 | 18 | class SlimScrollBar : public QScrollBar 19 | { 20 | Q_OBJECT 21 | public: 22 | SlimScrollBar(QWidget* parent = nullptr); 23 | 24 | /** 25 | * 鼠标松开时抖动动画 26 | * 松开的时候计算每一次抖动距离+时间,放入队列中 27 | * 定时调整抖动的队列实体索引 28 | */ 29 | struct Jitter 30 | { 31 | Jitter(QPoint p, qint64 t) : point(p), timestamp(t) {} 32 | QPoint point; // 要运动到的目标坐标 33 | qint64 timestamp; // 运动到目标坐标应该的时间戳,结束后删除本次抖动路径对象 34 | }; 35 | 36 | /** 37 | * 鼠标按下/弹起水波纹动画 38 | * 鼠标按下时动画速度慢(压住),松开后动画速度骤然加快 39 | * 同样用队列记录所有的水波纹动画实体 40 | */ 41 | struct Water 42 | { 43 | Water(QPoint p, qint64 t) : point(p), press_timestamp(t), 44 | release_timestamp(0), finish_timestamp(0), finished(false) {} 45 | QPoint point; 46 | qint64 press_timestamp; // 鼠标按下时间戳 47 | qint64 release_timestamp; // 鼠标松开时间戳。与按下时间戳、现行时间戳一起成为水波纹进度计算参数 48 | qint64 finish_timestamp; // 结束时间戳。与当前时间戳相减则为渐变消失经过的时间戳 49 | bool finished; // 是否结束。结束后改为渐变消失 50 | }; 51 | 52 | void enable(); 53 | void disable(); 54 | void setBgColors(QColor normal, QColor hover, QColor press); 55 | void setFgColors(QColor normal, QColor hover, QColor press); 56 | void setRoundCap(bool round); 57 | 58 | protected: 59 | void enterEvent(QEvent* e) override; 60 | void leaveEvent(QEvent* e) override; 61 | void mousePressEvent(QMouseEvent *e) override; 62 | void mouseMoveEvent(QMouseEvent *e) override; 63 | void mouseReleaseEvent(QMouseEvent *e) override; 64 | void wheelEvent(QWheelEvent *e) override; 65 | void paintEvent(QPaintEvent *e) override; 66 | void sliderChange(SliderChange change) override; 67 | void contextMenuEvent(QContextMenuEvent *e) override; 68 | void hideEvent(QHideEvent *e) override; 69 | void resizeEvent(QResizeEvent *e) override; 70 | 71 | private: 72 | void paintPixmap(); 73 | void activeTimer(); 74 | void setOffsetPoss(); 75 | int quick_sqrt(long X) const; 76 | void calcPixmapSize(); 77 | void startPopup(); 78 | void repaintPopup(); 79 | void setJitter(); 80 | qint64 getTimestamp(); 81 | inline QPen getPen(QColor color, int width); 82 | 83 | signals: 84 | 85 | public slots: 86 | 87 | private slots: 88 | void eventTimer(); 89 | 90 | private: 91 | QPixmap pixmap; 92 | QTimer* event_timer; 93 | 94 | QColor bg_normal_color = QColor(0xF0, 0xF0, 0xF0, 64); 95 | QColor bg_hover_color = QColor(0xF0, 0xF0, 0xF0, 128); 96 | QColor bg_press_color = QColor(0xF0, 0xF0, 0xF0, 192); 97 | QColor fg_normal_color = QColor(0xCC, 0xCC, 0xCC, 64); 98 | QColor fg_hover_color = QColor(0xCC, 0xCC, 0xCC, 128); 99 | QColor fg_press_color = QColor(0xCC, 0xCC, 0xCC, 192); 100 | bool round_cap = false; 101 | 102 | bool enabling = true; 103 | bool hovering = false; 104 | bool pressing = false; 105 | int hover_prop = 0; 106 | int press_prop = 0; 107 | QPoint press_pos; // 按下位置 108 | QPoint mouse_pos; // 鼠标位置 109 | QPoint target_pos; // 实时随队鼠标的目标点(相对竖直中心) 110 | QPoint anchor_pos; // 逐步靠近目标点的锚点 111 | QPoint effect_pos; // 偏差(相对于左上角),逐步靠近锚点根号位置 112 | 113 | bool popuping = false; 114 | SlimScrollBarPopup* popup = nullptr; 115 | QPoint popup_offset; // 弹窗和自己的左上角的绝对位置差 116 | 117 | double elastic_coefficient; // 弹性系数 118 | QList jitters; 119 | int jitter_duration; 120 | 121 | QList waters; 122 | int water_press_duration, water_release_duration, water_finish_duration; 123 | int water_radius; 124 | }; 125 | 126 | #endif // SLIMSCROLLBAR_H 127 | -------------------------------------------------------------------------------- /slim_scroll_bar/slimscrollbarpopup.cpp: -------------------------------------------------------------------------------- 1 | #include "slimscrollbarpopup.h" 2 | 3 | SlimScrollBarPopup::SlimScrollBarPopup(QWidget *parent) : QWidget(parent) 4 | { 5 | setAttribute(Qt::WA_TransparentForMouseEvents,true); 6 | setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::ToolTip); 7 | setAttribute(Qt::WA_TranslucentBackground); 8 | setFocusPolicy(Qt::NoFocus); 9 | } 10 | 11 | void SlimScrollBarPopup::paintEvent(QPaintEvent *) 12 | { 13 | QPainter painter(this); 14 | // painter.fillRect(0, 0, width()-1, height()-1, QColor(0x33, 0xFF, 0xff, 0x33)); 15 | 16 | painter.drawPixmap(QPoint(0,0), scrollbar_pixmap); 17 | // painter.drawPixmap(offset, scrollbar_pixmap); 18 | } 19 | -------------------------------------------------------------------------------- /slim_scroll_bar/slimscrollbarpopup.h: -------------------------------------------------------------------------------- 1 | #ifndef SLIMSCROLLBARPOPUP_H 2 | #define SLIMSCROLLBARPOPUP_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class SlimScrollBarPopup : public QWidget 11 | { 12 | Q_OBJECT 13 | friend class SlimScrollBar; 14 | public: 15 | SlimScrollBarPopup(QWidget *parent = nullptr); 16 | 17 | protected: 18 | void paintEvent(QPaintEvent *) override; 19 | 20 | signals: 21 | 22 | public slots: 23 | 24 | private: 25 | QPixmap scrollbar_pixmap; 26 | QPoint offset; 27 | }; 28 | 29 | #endif // SLIMSCROLLBARPOPUP_H 30 | -------------------------------------------------------------------------------- /果冻条.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iwxyi/Qt-SlimScrollBar/349cb70b027d35b71ec0ed8358793363d6a34d27/果冻条.gif --------------------------------------------------------------------------------