├── .gitattributes ├── .gitignore ├── ColorDialog ├── BasicColorArea.cpp ├── BasicColorArea.h ├── BasicColorItem.cpp ├── BasicColorItem.h ├── ColorDialog.cpp ├── ColorDialog.h ├── ColorDialog.ui ├── ColorTest.cpp ├── ColorTest.h ├── ColorTest.pro ├── ColorTest.pro.user ├── ColorTest.ui ├── CustomColorArea.cpp ├── CustomColorArea.h ├── HColorArea.cpp ├── HColorArea.h ├── PreviewColorArea.cpp ├── PreviewColorArea.h ├── SVColorArea.cpp ├── SVColorArea.h ├── data │ ├── images │ │ ├── button │ │ │ ├── button-h.png │ │ │ ├── button-n.png │ │ │ └── button-s.png │ │ └── mainui │ │ │ ├── bg.png │ │ │ ├── close-H.png │ │ │ ├── close.png │ │ │ ├── main.png │ │ │ ├── max-H.png │ │ │ ├── max.png │ │ │ ├── min-H.png │ │ │ ├── min.png │ │ │ └── title.png │ └── ui.png ├── main.cpp └── readme.md ├── DefineAndUseModule ├── StyleDemo │ ├── CustomControl │ │ ├── controls │ │ │ ├── ButtonColor.qml │ │ │ ├── ButtonColor.qmlc │ │ │ ├── CustomButton.qml │ │ │ ├── CustomButton.qmlc │ │ │ ├── CustomProperty.qml │ │ │ └── CustomProperty.qmlc │ │ └── qmldir │ ├── StyleDemo.pro │ ├── StyleDemo.pro.user │ ├── main.cpp │ ├── main.qml │ └── qml.qrc └── readme.md ├── HttpRequestTest ├── HttpRequestTest.pro ├── HttpRequestTest.pro.user ├── main.cpp ├── main.qml ├── qml.qrc └── readme.md ├── MessagBox ├── README.md ├── SimpleMsgBox.cpp ├── SimpleMsgBox.h ├── SimpleMsgBox.ui └── image │ ├── bg.png │ ├── close - 副本.png │ ├── close.png │ ├── demo.png │ ├── notice.png │ └── top.png ├── QThreadTest ├── GetPostThread.py ├── SingleThreadTest.py ├── ThreadTestUI.py └── readme.md ├── SgsClub ├── Control │ ├── Config.py │ ├── HomePageThread.py │ ├── LoginThread.py │ ├── PostPageThread.py │ ├── SgsClub.py │ ├── __pycache__ │ │ ├── HomePageThread.cpython-35.pyc │ │ ├── PostPageThread.cpython-35.pyc │ │ └── SgsClub.cpython-35.pyc │ ├── test.py │ └── test1.py ├── View │ ├── BottomButton.py │ ├── BottomPart.py │ ├── HomePostsWidget.py │ ├── HomeTop.py │ ├── LoginWidget.py │ ├── PostTopWidget.py │ ├── ReplyPostWidget.py │ ├── ResizableWidget.py │ ├── SgsClubMain.py │ ├── SinglePostWidget.py │ ├── __pycache__ │ │ ├── BottomButton.cpython-35.pyc │ │ ├── BottomPart.cpython-35.pyc │ │ ├── HomePostsWidget.cpython-35.pyc │ │ ├── HomeTop.cpython-35.pyc │ │ ├── LoginWidget.cpython-35.pyc │ │ ├── PostTopWidget.cpython-35.pyc │ │ ├── ReplyPostWidget.cpython-35.pyc │ │ ├── ResizableWidget.cpython-35.pyc │ │ └── SinglePostWidget.cpython-35.pyc │ ├── cookie.json │ ├── css │ │ ├── homeposts.css │ │ └── post.css │ ├── js │ │ └── post.js │ ├── pages │ │ └── post.html │ └── ttt.py └── data │ ├── images │ ├── bottom │ │ ├── bulletscreen_icon_zoomin_excessive.png │ │ ├── card_icon_arrow.png │ │ ├── compose_more_app_add_highlighted.png │ │ ├── home_1s.png │ │ ├── home_3n.png │ │ ├── home_n.png │ │ ├── home_s.png │ │ ├── icon_1_new_d.png │ │ ├── icon_1_new_n.png │ │ ├── icon_2_new_d.png │ │ ├── icon_2_new_n.png │ │ ├── icon_3_new_d.png │ │ ├── icon_3_new_n.png │ │ ├── market_icon_search_normal.png │ │ ├── me_1n.png │ │ ├── me_1s.png │ │ ├── me_n.png │ │ ├── me_s.png │ │ ├── msg_1n.png │ │ ├── msg_n.png │ │ ├── msg_s.png │ │ ├── msg_s1.png │ │ ├── navigationbar_friendattention.png │ │ ├── navigationbar_friendattention_dot.png │ │ ├── navigationbar_friendattention_dot_highlighted.png │ │ ├── navigationbar_friendattention_highlighted.png │ │ ├── navigationbar_home.png │ │ ├── navigationbar_home_highlighted.png │ │ ├── navigationbar_icon_health_mine.png │ │ ├── navigationbar_icon_health_mine_highlighted.png │ │ ├── navigationbar_icon_health_mine_white.png │ │ ├── navigationbar_icon_health_mine_white_highlighted.png │ │ ├── post_1n.png │ │ ├── post_n.png │ │ ├── search_n.png │ │ ├── search_s.png │ │ ├── tabbar_compose_icon_add@3x.png │ │ ├── tabbar_discover@3x.png │ │ ├── tabbar_discover_highlighted@2x.png │ │ ├── tabbar_discover_highlighted@3x.png │ │ ├── tabbar_discover_selected@3x.png │ │ ├── tabbar_home@3x.png │ │ ├── tabbar_home_highlighted@3x.png │ │ ├── tabbar_home_selected@2x.png │ │ ├── tabbar_home_selected@3x.png │ │ ├── tabbar_message_center@3x.png │ │ ├── tabbar_message_center_highlighted@3x.png │ │ ├── tabbar_message_center_selected@2x.png │ │ ├── tabbar_message_center_selected@3x.png │ │ ├── tabbar_profile@3x.png │ │ ├── tabbar_profile_highlighted@3x.png │ │ ├── tabbar_profile_selected@2x.png │ │ └── tabbar_profile_selected@3x.png │ ├── hometop │ │ ├── friend.png │ │ ├── hh.png │ │ └── hi.png │ ├── login │ │ └── logo.png │ └── posttop │ │ ├── home.png │ │ └── temp.png │ └── style │ ├── bottom.css │ ├── hometop.css │ ├── login.css │ ├── main.css │ ├── post.css │ ├── posttop.css │ └── reply.css ├── StyleSheetDemo ├── StyleSheetDemo.pro ├── StyleSheetDemo.pro.user ├── StyleTest.cpp ├── StyleTest.h ├── StyleTest.ui ├── images.qrc ├── images │ ├── button │ │ ├── button-h.png │ │ ├── button-n.png │ │ └── button-s.png │ ├── checkbox │ │ ├── check.png │ │ └── uncheck.png │ ├── progressbar │ │ ├── prog.png │ │ ├── prog1.png │ │ ├── prog2.png │ │ └── prog3.png │ ├── radiobutton │ │ ├── checked.png │ │ ├── checked_disabled.png │ │ ├── checked_focus.png │ │ ├── unchecked.png │ │ ├── unchecked_disabled.png │ │ └── unchecked_focus.png │ ├── slider │ │ ├── ply_btn.png │ │ └── ply_btn_hvr.png │ └── tree │ │ ├── collapse.png │ │ └── expand.png ├── main.cpp └── readme.md ├── TreeSearch ├── README.md ├── demo.png ├── model-view │ ├── TreeSearch.cpp │ └── TreeSearch.h └── normal │ ├── TreeSearch.cpp │ └── TreeSearch.h └── WebSocket ├── WebSocketTest.cpp ├── WebSocketTest.h ├── WebSocketTest.qrc ├── WebSocketTest.ui ├── client.html └── main.cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /ColorDialog/BasicColorArea.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "BasicColorArea.h" 4 | 5 | BasicColorArea::BasicColorArea(QWidget *parent) 6 | : QWidget(parent) 7 | { 8 | initColorItems(); 9 | } 10 | 11 | BasicColorArea::~BasicColorArea() 12 | { 13 | 14 | } 15 | 16 | void BasicColorArea::initColorItems() 17 | { 18 | BasicColorItem *pItem11 = new BasicColorItem(QColor(0, 0, 0)); 19 | BasicColorItem *pItem12 = new BasicColorItem(QColor(51, 51, 51)); 20 | BasicColorItem *pItem13 = new BasicColorItem(QColor(102, 102, 102)); 21 | BasicColorItem *pItem14 = new BasicColorItem(QColor(153, 153, 153)); 22 | BasicColorItem *pItem15 = new BasicColorItem(QColor(204, 204, 204)); 23 | BasicColorItem *pItem16 = new BasicColorItem(QColor(221, 221, 221)); 24 | BasicColorItem *pItem17 = new BasicColorItem(QColor(238, 238, 238)); 25 | BasicColorItem *pItem18 = new BasicColorItem(QColor(255, 255, 255)); 26 | QHBoxLayout *pLayout1 = new QHBoxLayout; 27 | pLayout1->setMargin(0); 28 | pLayout1->setSpacing(2); 29 | pLayout1->addWidget(pItem11); 30 | pLayout1->addWidget(pItem12); 31 | pLayout1->addWidget(pItem13); 32 | pLayout1->addWidget(pItem14); 33 | pLayout1->addWidget(pItem15); 34 | pLayout1->addWidget(pItem16); 35 | pLayout1->addWidget(pItem17); 36 | pLayout1->addWidget(pItem18); 37 | 38 | BasicColorItem *pItem21 = new BasicColorItem(QColor(207, 42, 39)); 39 | BasicColorItem *pItem22 = new BasicColorItem(QColor(255, 153, 0)); 40 | BasicColorItem *pItem23 = new BasicColorItem(QColor(255, 255, 0)); 41 | BasicColorItem *pItem24 = new BasicColorItem(QColor(0, 158, 15)); 42 | BasicColorItem *pItem25 = new BasicColorItem(QColor(0, 255, 255)); 43 | BasicColorItem *pItem26 = new BasicColorItem(QColor(43, 120, 228)); 44 | BasicColorItem *pItem27 = new BasicColorItem(QColor(153, 0, 255)); 45 | BasicColorItem *pItem28 = new BasicColorItem(QColor(255, 0, 255)); 46 | QHBoxLayout *pLayout2 = new QHBoxLayout; 47 | pLayout2->setMargin(0); 48 | pLayout2->setSpacing(2); 49 | pLayout2->addWidget(pItem21); 50 | pLayout2->addWidget(pItem22); 51 | pLayout2->addWidget(pItem23); 52 | pLayout2->addWidget(pItem24); 53 | pLayout2->addWidget(pItem25); 54 | pLayout2->addWidget(pItem26); 55 | pLayout2->addWidget(pItem27); 56 | pLayout2->addWidget(pItem28); 57 | 58 | BasicColorItem *pItem31 = new BasicColorItem(QColor(234, 153, 153)); 59 | BasicColorItem *pItem32 = new BasicColorItem(QColor(249, 203, 156)); 60 | BasicColorItem *pItem33 = new BasicColorItem(QColor(255, 229, 153)); 61 | BasicColorItem *pItem34 = new BasicColorItem(QColor(182, 215, 168)); 62 | BasicColorItem *pItem35 = new BasicColorItem(QColor(162, 196, 201)); 63 | BasicColorItem *pItem36 = new BasicColorItem(QColor(159, 197, 248)); 64 | BasicColorItem *pItem37 = new BasicColorItem(QColor(180, 167, 214)); 65 | BasicColorItem *pItem38 = new BasicColorItem(QColor(213, 166, 189)); 66 | QHBoxLayout *pLayout3 = new QHBoxLayout; 67 | pLayout3->setMargin(0); 68 | pLayout3->setSpacing(2); 69 | pLayout3->addWidget(pItem31); 70 | pLayout3->addWidget(pItem32); 71 | pLayout3->addWidget(pItem33); 72 | pLayout3->addWidget(pItem34); 73 | pLayout3->addWidget(pItem35); 74 | pLayout3->addWidget(pItem36); 75 | pLayout3->addWidget(pItem37); 76 | pLayout3->addWidget(pItem38); 77 | 78 | BasicColorItem *pItem41 = new BasicColorItem(QColor(224, 102, 102)); 79 | BasicColorItem *pItem42 = new BasicColorItem(QColor(246, 178, 107)); 80 | BasicColorItem *pItem43 = new BasicColorItem(QColor(255, 217, 102)); 81 | BasicColorItem *pItem44 = new BasicColorItem(QColor(147, 196, 125)); 82 | BasicColorItem *pItem45 = new BasicColorItem(QColor(118, 165, 175)); 83 | BasicColorItem *pItem46 = new BasicColorItem(QColor(111, 168, 220)); 84 | BasicColorItem *pItem47 = new BasicColorItem(QColor(142, 124, 195)); 85 | BasicColorItem *pItem48 = new BasicColorItem(QColor(194, 123, 160)); 86 | QHBoxLayout *pLayout4 = new QHBoxLayout; 87 | pLayout4->setMargin(0); 88 | pLayout4->setSpacing(2); 89 | pLayout4->addWidget(pItem41); 90 | pLayout4->addWidget(pItem42); 91 | pLayout4->addWidget(pItem43); 92 | pLayout4->addWidget(pItem44); 93 | pLayout4->addWidget(pItem45); 94 | pLayout4->addWidget(pItem46); 95 | pLayout4->addWidget(pItem47); 96 | pLayout4->addWidget(pItem48); 97 | 98 | BasicColorItem *pItem51 = new BasicColorItem(QColor(204, 0, 0)); 99 | BasicColorItem *pItem52 = new BasicColorItem(QColor(230, 145, 56)); 100 | BasicColorItem *pItem53 = new BasicColorItem(QColor(241, 194, 50)); 101 | BasicColorItem *pItem54 = new BasicColorItem(QColor(106, 168, 79)); 102 | BasicColorItem *pItem55 = new BasicColorItem(QColor(69, 129, 142)); 103 | BasicColorItem *pItem56 = new BasicColorItem(QColor(89, 126, 170)); 104 | BasicColorItem *pItem57 = new BasicColorItem(QColor(103, 78, 167)); 105 | BasicColorItem *pItem58 = new BasicColorItem(QColor(166, 77, 121)); 106 | QHBoxLayout *pLayout5 = new QHBoxLayout; 107 | pLayout5->setMargin(0); 108 | pLayout5->setSpacing(2); 109 | pLayout5->addWidget(pItem51); 110 | pLayout5->addWidget(pItem52); 111 | pLayout5->addWidget(pItem53); 112 | pLayout5->addWidget(pItem54); 113 | pLayout5->addWidget(pItem55); 114 | pLayout5->addWidget(pItem56); 115 | pLayout5->addWidget(pItem57); 116 | pLayout5->addWidget(pItem58); 117 | 118 | BasicColorItem *pItem61 = new BasicColorItem(QColor(153, 0, 0)); 119 | BasicColorItem *pItem62 = new BasicColorItem(QColor(180, 95, 6)); 120 | BasicColorItem *pItem63 = new BasicColorItem(QColor(119, 144, 0)); 121 | BasicColorItem *pItem64 = new BasicColorItem(QColor(56, 118, 29)); 122 | BasicColorItem *pItem65 = new BasicColorItem(QColor(19, 79, 92)); 123 | BasicColorItem *pItem66 = new BasicColorItem(QColor(8, 83, 148)); 124 | BasicColorItem *pItem67 = new BasicColorItem(QColor(52, 28, 117)); 125 | BasicColorItem *pItem68 = new BasicColorItem(QColor(116, 27, 71)); 126 | QHBoxLayout *pLayout6 = new QHBoxLayout; 127 | pLayout6->setMargin(0); 128 | pLayout6->setSpacing(2); 129 | pLayout6->addWidget(pItem61); 130 | pLayout6->addWidget(pItem62); 131 | pLayout6->addWidget(pItem63); 132 | pLayout6->addWidget(pItem64); 133 | pLayout6->addWidget(pItem65); 134 | pLayout6->addWidget(pItem66); 135 | pLayout6->addWidget(pItem67); 136 | pLayout6->addWidget(pItem68); 137 | 138 | BasicColorItem *pItem71 = new BasicColorItem(QColor(102, 0, 0)); 139 | BasicColorItem *pItem72 = new BasicColorItem(QColor(120, 63, 4)); 140 | BasicColorItem *pItem73 = new BasicColorItem(QColor(127, 96, 0)); 141 | BasicColorItem *pItem74 = new BasicColorItem(QColor(39, 78, 19)); 142 | BasicColorItem *pItem75 = new BasicColorItem(QColor(12, 52, 61)); 143 | BasicColorItem *pItem76 = new BasicColorItem(QColor(7, 55, 99)); 144 | BasicColorItem *pItem77 = new BasicColorItem(QColor(32, 18, 77)); 145 | BasicColorItem *pItem78 = new BasicColorItem(QColor(71, 17, 48)); 146 | QHBoxLayout *pLayout7 = new QHBoxLayout; 147 | pLayout7->setMargin(0); 148 | pLayout7->setSpacing(2); 149 | pLayout7->addWidget(pItem71); 150 | pLayout7->addWidget(pItem72); 151 | pLayout7->addWidget(pItem73); 152 | pLayout7->addWidget(pItem74); 153 | pLayout7->addWidget(pItem75); 154 | pLayout7->addWidget(pItem76); 155 | pLayout7->addWidget(pItem77); 156 | pLayout7->addWidget(pItem78); 157 | 158 | QVBoxLayout *pVLayout = new QVBoxLayout(this); 159 | pVLayout->setMargin(0); 160 | pVLayout->setSpacing(2); 161 | pVLayout->addLayout(pLayout1); 162 | pVLayout->addLayout(pLayout2); 163 | pVLayout->addLayout(pLayout3); 164 | pVLayout->addLayout(pLayout4); 165 | pVLayout->addLayout(pLayout5); 166 | pVLayout->addLayout(pLayout6); 167 | pVLayout->addLayout(pLayout7); 168 | 169 | connect(pItem11, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 170 | connect(pItem12, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 171 | connect(pItem13, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 172 | connect(pItem14, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 173 | connect(pItem15, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 174 | connect(pItem16, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 175 | connect(pItem17, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 176 | connect(pItem18, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 177 | 178 | connect(pItem21, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 179 | connect(pItem22, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 180 | connect(pItem23, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 181 | connect(pItem24, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 182 | connect(pItem25, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 183 | connect(pItem26, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 184 | connect(pItem27, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 185 | connect(pItem28, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 186 | 187 | connect(pItem31, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 188 | connect(pItem32, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 189 | connect(pItem33, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 190 | connect(pItem34, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 191 | connect(pItem35, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 192 | connect(pItem36, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 193 | connect(pItem37, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 194 | connect(pItem38, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 195 | 196 | connect(pItem41, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 197 | connect(pItem42, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 198 | connect(pItem43, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 199 | connect(pItem44, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 200 | connect(pItem45, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 201 | connect(pItem46, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 202 | connect(pItem47, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 203 | connect(pItem48, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 204 | 205 | connect(pItem51, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 206 | connect(pItem52, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 207 | connect(pItem53, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 208 | connect(pItem54, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 209 | connect(pItem55, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 210 | connect(pItem56, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 211 | connect(pItem57, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 212 | connect(pItem58, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 213 | 214 | connect(pItem61, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 215 | connect(pItem62, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 216 | connect(pItem63, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 217 | connect(pItem64, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 218 | connect(pItem65, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 219 | connect(pItem66, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 220 | connect(pItem67, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 221 | connect(pItem68, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 222 | 223 | connect(pItem71, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 224 | connect(pItem72, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 225 | connect(pItem73, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 226 | connect(pItem74, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 227 | connect(pItem75, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 228 | connect(pItem76, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 229 | connect(pItem77, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 230 | connect(pItem78, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 231 | } 232 | -------------------------------------------------------------------------------- /ColorDialog/BasicColorArea.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/BasicColorArea.h -------------------------------------------------------------------------------- /ColorDialog/BasicColorItem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "BasicColorItem.h" 3 | 4 | #define ITEM_EDGE_LENGTH 25 5 | 6 | BasicColorItem::BasicColorItem(const QColor &c, QWidget *parent) 7 | : QLabel(parent) 8 | , m_bMouseIn(false) 9 | { 10 | setFixedSize(ITEM_EDGE_LENGTH, ITEM_EDGE_LENGTH); 11 | setColor(c); 12 | } 13 | 14 | BasicColorItem::~BasicColorItem() 15 | { 16 | 17 | } 18 | 19 | QColor BasicColorItem::getColor() 20 | { 21 | return m_color; 22 | } 23 | 24 | void BasicColorItem::paintEvent(QPaintEvent *ev) 25 | { 26 | __super::paintEvent(ev); 27 | if (m_bMouseIn) 28 | { 29 | QPainter painter(this); 30 | painter.setCompositionMode(QPainter::CompositionMode_Source); 31 | painter.setPen(QPen(Qt::white, 3)); 32 | painter.drawRect(1, 1, ITEM_EDGE_LENGTH - 3, ITEM_EDGE_LENGTH - 3); 33 | } 34 | } 35 | 36 | void BasicColorItem::mousePressEvent(QMouseEvent *) 37 | { 38 | emit itemClickedSignal(m_color); 39 | } 40 | 41 | void BasicColorItem::enterEvent(QEvent *) 42 | { 43 | m_bMouseIn = true; 44 | update(); 45 | } 46 | 47 | void BasicColorItem::leaveEvent(QEvent *) 48 | { 49 | m_bMouseIn = false; 50 | update(); 51 | } 52 | 53 | void BasicColorItem::setColor(const QColor &c) 54 | { 55 | m_color = c; 56 | QImage itemImg = QImage(ITEM_EDGE_LENGTH, ITEM_EDGE_LENGTH, QImage::Format_RGB32); 57 | QPainter painter(&itemImg); 58 | painter.setRenderHint(QPainter::Antialiasing); 59 | painter.setCompositionMode(QPainter::CompositionMode_Source); 60 | painter.drawImage(0, 0, itemImg); 61 | painter.setPen(Qt::NoPen); 62 | painter.setBrush(c); 63 | painter.drawRect(0, 0, width(), height()); 64 | painter.end(); 65 | this->setPixmap(QPixmap::fromImage(itemImg)); 66 | update(); 67 | } 68 | -------------------------------------------------------------------------------- /ColorDialog/BasicColorItem.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/BasicColorItem.h -------------------------------------------------------------------------------- /ColorDialog/ColorDialog.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/ColorDialog.cpp -------------------------------------------------------------------------------- /ColorDialog/ColorDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef COLORDIALOG_H 2 | #define COLORDIALOG_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class ColorDialog : public QWidget 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | enum ButtonRole{Yes, No}; 15 | ColorDialog(QWidget *parent = 0); 16 | ~ColorDialog(); 17 | ButtonRole showDialog(); 18 | void setCurColor(const QColor &); 19 | QColor getColor(); 20 | QRgb getRgb(); 21 | 22 | protected: 23 | bool eventFilter(QObject *, QEvent *); 24 | void show(); 25 | 26 | private: 27 | void initSignalAndSlotConn(); 28 | void updateRGBColor(const QColor &); 29 | 30 | private slots: 31 | void colorItemSelcSlot(const QColor &); 32 | void addCustomColorSlot(); 33 | void okBtnClickedSlot(); 34 | void cancelBtnClickedSlot(); 35 | void editChangedSlot(const QString &); 36 | void editFinishedSlot(); 37 | 38 | void hValueChangedSlot(int); 39 | void sValueChangedSlot(int); 40 | void vValueChangedSlot(int); 41 | void rValueChangedSlot(int); 42 | void gValueChangedSlot(int); 43 | void bValueChangedSlot(int); 44 | 45 | void updateEditData(int, int, int); 46 | 47 | private: 48 | class ColorSetting; 49 | ColorSetting * const m_pSetting; 50 | QLabel *m_pTitleLbl; 51 | QPushButton *m_pCloseBtn; 52 | QEventLoop *m_pEvtLoop; 53 | ButtonRole m_buttonRole; 54 | bool m_bNotEdit; 55 | }; 56 | 57 | #endif // COLORDIALOG_H 58 | -------------------------------------------------------------------------------- /ColorDialog/ColorTest.cpp: -------------------------------------------------------------------------------- 1 | #include "colortest.h" 2 | #include "ui_colortest.h" 3 | 4 | ColorTest::ColorTest(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::ColorTest), 7 | m_pColorDlg(NULL) 8 | { 9 | ui->setupUi(this); 10 | connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(showColorDlg())); 11 | } 12 | 13 | ColorTest::~ColorTest() 14 | { 15 | delete ui; 16 | } 17 | 18 | void ColorTest::showColorDlg() 19 | { 20 | if(m_pColorDlg == NULL) 21 | { 22 | m_pColorDlg = new ColorDialog(this); 23 | } 24 | m_pColorDlg->showDialog(); 25 | } 26 | -------------------------------------------------------------------------------- /ColorDialog/ColorTest.h: -------------------------------------------------------------------------------- 1 | #ifndef COLORTEST_H 2 | #define COLORTEST_H 3 | 4 | #include 5 | #include "ColorDialog.h" 6 | 7 | namespace Ui { 8 | class ColorTest; 9 | } 10 | 11 | class ColorTest : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit ColorTest(QWidget *parent = 0); 17 | ~ColorTest(); 18 | 19 | private slots: 20 | void showColorDlg(); 21 | 22 | private: 23 | Ui::ColorTest *ui; 24 | ColorDialog *m_pColorDlg; 25 | }; 26 | 27 | #endif // COLORTEST_H 28 | -------------------------------------------------------------------------------- /ColorDialog/ColorTest.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2017-02-09T19:24:35 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = ColorTest 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which as been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | 26 | SOURCES += main.cpp\ 27 | ColorTest.cpp \ 28 | BasicColorArea.cpp \ 29 | BasicColorItem.cpp \ 30 | ColorDialog.cpp \ 31 | CustomColorArea.cpp \ 32 | HColorArea.cpp \ 33 | PreviewColorArea.cpp \ 34 | SVColorArea.cpp 35 | 36 | HEADERS += ColorTest.h \ 37 | BasicColorArea.h \ 38 | BasicColorItem.h \ 39 | ColorDialog.h \ 40 | CustomColorArea.h \ 41 | HColorArea.h \ 42 | PreviewColorArea.h \ 43 | SVColorArea.h 44 | 45 | FORMS += ColorTest.ui \ 46 | ColorDialog.ui 47 | -------------------------------------------------------------------------------- /ColorDialog/ColorTest.pro.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EnvironmentId 7 | {e61abb9a-4b09-4921-868c-1c74f1276754} 8 | 9 | 10 | ProjectExplorer.Project.ActiveTarget 11 | 0 12 | 13 | 14 | ProjectExplorer.Project.EditorSettings 15 | 16 | true 17 | false 18 | true 19 | 20 | Cpp 21 | 22 | CppGlobal 23 | 24 | 25 | 26 | QmlJS 27 | 28 | QmlJSGlobal 29 | 30 | 31 | 2 32 | UTF-8 33 | false 34 | 4 35 | false 36 | 80 37 | true 38 | true 39 | 1 40 | true 41 | false 42 | 0 43 | true 44 | true 45 | 0 46 | 8 47 | true 48 | 1 49 | true 50 | true 51 | true 52 | false 53 | 54 | 55 | 56 | ProjectExplorer.Project.PluginSettings 57 | 58 | 59 | 60 | ProjectExplorer.Project.Target.0 61 | 62 | Desktop Qt 5.8.0 MSVC2015 32bit 63 | Desktop Qt 5.8.0 MSVC2015 32bit 64 | qt.58.win32_msvc2015_kit 65 | 0 66 | 0 67 | 0 68 | 69 | C:/Users/kong/Desktop/build-ColorTest-Desktop_Qt_5_8_0_MSVC2015_32bit-Debug 70 | 71 | 72 | true 73 | qmake 74 | 75 | QtProjectManager.QMakeBuildStep 76 | true 77 | 78 | false 79 | false 80 | false 81 | 82 | 83 | true 84 | Make 85 | 86 | Qt4ProjectManager.MakeStep 87 | 88 | false 89 | 90 | 91 | 92 | 2 93 | 构建 94 | 95 | ProjectExplorer.BuildSteps.Build 96 | 97 | 98 | 99 | true 100 | Make 101 | 102 | Qt4ProjectManager.MakeStep 103 | 104 | true 105 | clean 106 | 107 | 108 | 1 109 | 清理 110 | 111 | ProjectExplorer.BuildSteps.Clean 112 | 113 | 2 114 | false 115 | 116 | Debug 117 | 118 | Qt4ProjectManager.Qt4BuildConfiguration 119 | 2 120 | true 121 | 122 | 123 | C:/Users/kong/Desktop/build-ColorTest-Desktop_Qt_5_8_0_MSVC2015_32bit-Release 124 | 125 | 126 | true 127 | qmake 128 | 129 | QtProjectManager.QMakeBuildStep 130 | false 131 | 132 | false 133 | false 134 | false 135 | 136 | 137 | true 138 | Make 139 | 140 | Qt4ProjectManager.MakeStep 141 | 142 | false 143 | 144 | 145 | 146 | 2 147 | 构建 148 | 149 | ProjectExplorer.BuildSteps.Build 150 | 151 | 152 | 153 | true 154 | Make 155 | 156 | Qt4ProjectManager.MakeStep 157 | 158 | true 159 | clean 160 | 161 | 162 | 1 163 | 清理 164 | 165 | ProjectExplorer.BuildSteps.Clean 166 | 167 | 2 168 | false 169 | 170 | Release 171 | 172 | Qt4ProjectManager.Qt4BuildConfiguration 173 | 0 174 | true 175 | 176 | 177 | C:/Users/kong/Desktop/build-ColorTest-Desktop_Qt_5_8_0_MSVC2015_32bit-Profile 178 | 179 | 180 | true 181 | qmake 182 | 183 | QtProjectManager.QMakeBuildStep 184 | true 185 | 186 | false 187 | true 188 | false 189 | 190 | 191 | true 192 | Make 193 | 194 | Qt4ProjectManager.MakeStep 195 | 196 | false 197 | 198 | 199 | 200 | 2 201 | 构建 202 | 203 | ProjectExplorer.BuildSteps.Build 204 | 205 | 206 | 207 | true 208 | Make 209 | 210 | Qt4ProjectManager.MakeStep 211 | 212 | true 213 | clean 214 | 215 | 216 | 1 217 | 清理 218 | 219 | ProjectExplorer.BuildSteps.Clean 220 | 221 | 2 222 | false 223 | 224 | Profile 225 | 226 | Qt4ProjectManager.Qt4BuildConfiguration 227 | 0 228 | true 229 | 230 | 3 231 | 232 | 233 | 0 234 | 部署 235 | 236 | ProjectExplorer.BuildSteps.Deploy 237 | 238 | 1 239 | 在本地部署 240 | 241 | ProjectExplorer.DefaultDeployConfiguration 242 | 243 | 1 244 | 245 | 246 | false 247 | false 248 | 1000 249 | 250 | true 251 | 252 | false 253 | false 254 | false 255 | false 256 | true 257 | 0.01 258 | 10 259 | true 260 | 1 261 | 25 262 | 263 | 1 264 | true 265 | false 266 | true 267 | valgrind 268 | 269 | 0 270 | 1 271 | 2 272 | 3 273 | 4 274 | 5 275 | 6 276 | 7 277 | 8 278 | 9 279 | 10 280 | 11 281 | 12 282 | 13 283 | 14 284 | 285 | 2 286 | 287 | ColorTest 288 | 289 | Qt4ProjectManager.Qt4RunConfiguration:C:/Users/kong/Desktop/11/ColorTest.pro 290 | true 291 | 292 | ColorTest.pro 293 | false 294 | 295 | C:/Users/kong/Desktop/build-ColorTest-Desktop_Qt_5_8_0_MSVC2015_32bit-Debug 296 | 3768 297 | false 298 | true 299 | false 300 | false 301 | true 302 | 303 | 1 304 | 305 | 306 | 307 | ProjectExplorer.Project.TargetCount 308 | 1 309 | 310 | 311 | ProjectExplorer.Project.Updater.FileVersion 312 | 18 313 | 314 | 315 | Version 316 | 18 317 | 318 | 319 | -------------------------------------------------------------------------------- /ColorDialog/ColorTest.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ColorTest 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | ColorTest 15 | 16 | 17 | 18 | 19 | 160 20 | 110 21 | 75 22 | 23 23 | 24 | 25 | 26 | PushButton 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /ColorDialog/CustomColorArea.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "CustomColorArea.h" 4 | 5 | CustomColorArea::CustomColorArea(QWidget *parent) 6 | : QWidget(parent) 7 | , m_iCurIndex(0) 8 | { 9 | initColorItems(); 10 | } 11 | 12 | CustomColorArea::~CustomColorArea() 13 | { 14 | 15 | } 16 | 17 | void CustomColorArea::setGivenColor(const QColor &c) 18 | { 19 | int iIndex = m_iCurIndex % 16; 20 | BasicColorItem *pCurItem = m_mapIndexToItem[iIndex]; 21 | pCurItem->setColor(c); 22 | m_iCurIndex++; 23 | } 24 | 25 | void CustomColorArea::initColorItems() 26 | { 27 | BasicColorItem *pItem11 = new BasicColorItem(QColor(255, 255, 255)); 28 | BasicColorItem *pItem12 = new BasicColorItem(QColor(255, 255, 255)); 29 | BasicColorItem *pItem13 = new BasicColorItem(QColor(255, 255, 255)); 30 | BasicColorItem *pItem14 = new BasicColorItem(QColor(255, 255, 255)); 31 | BasicColorItem *pItem15 = new BasicColorItem(QColor(255, 255, 255)); 32 | BasicColorItem *pItem16 = new BasicColorItem(QColor(255, 255, 255)); 33 | BasicColorItem *pItem17 = new BasicColorItem(QColor(255, 255, 255)); 34 | BasicColorItem *pItem18 = new BasicColorItem(QColor(255, 255, 255)); 35 | QHBoxLayout *pLayout1 = new QHBoxLayout; 36 | pLayout1->setMargin(0); 37 | pLayout1->setSpacing(2); 38 | pLayout1->addWidget(pItem11); 39 | pLayout1->addWidget(pItem12); 40 | pLayout1->addWidget(pItem13); 41 | pLayout1->addWidget(pItem14); 42 | pLayout1->addWidget(pItem15); 43 | pLayout1->addWidget(pItem16); 44 | pLayout1->addWidget(pItem17); 45 | pLayout1->addWidget(pItem18); 46 | 47 | BasicColorItem *pItem21 = new BasicColorItem(QColor(255, 255, 255)); 48 | BasicColorItem *pItem22 = new BasicColorItem(QColor(255, 255, 255)); 49 | BasicColorItem *pItem23 = new BasicColorItem(QColor(255, 255, 255)); 50 | BasicColorItem *pItem24 = new BasicColorItem(QColor(255, 255, 255)); 51 | BasicColorItem *pItem25 = new BasicColorItem(QColor(255, 255, 255)); 52 | BasicColorItem *pItem26 = new BasicColorItem(QColor(255, 255, 255)); 53 | BasicColorItem *pItem27 = new BasicColorItem(QColor(255, 255, 255)); 54 | BasicColorItem *pItem28 = new BasicColorItem(QColor(255, 255, 255)); 55 | QHBoxLayout *pLayout2 = new QHBoxLayout; 56 | pLayout2->setMargin(0); 57 | pLayout2->setSpacing(2); 58 | pLayout2->addWidget(pItem21); 59 | pLayout2->addWidget(pItem22); 60 | pLayout2->addWidget(pItem23); 61 | pLayout2->addWidget(pItem24); 62 | pLayout2->addWidget(pItem25); 63 | pLayout2->addWidget(pItem26); 64 | pLayout2->addWidget(pItem27); 65 | pLayout2->addWidget(pItem28); 66 | 67 | QVBoxLayout *pVLayout = new QVBoxLayout(this); 68 | pVLayout->setMargin(0); 69 | pVLayout->setSpacing(2); 70 | pVLayout->addLayout(pLayout1); 71 | pVLayout->addLayout(pLayout2); 72 | 73 | m_mapIndexToItem.insert(0, pItem11); 74 | m_mapIndexToItem.insert(1, pItem21); 75 | m_mapIndexToItem.insert(2, pItem12); 76 | m_mapIndexToItem.insert(3, pItem22); 77 | m_mapIndexToItem.insert(4, pItem13); 78 | m_mapIndexToItem.insert(5, pItem23); 79 | m_mapIndexToItem.insert(6, pItem14); 80 | m_mapIndexToItem.insert(7, pItem24); 81 | m_mapIndexToItem.insert(8, pItem15); 82 | m_mapIndexToItem.insert(9, pItem25); 83 | m_mapIndexToItem.insert(10, pItem16); 84 | m_mapIndexToItem.insert(11, pItem26); 85 | m_mapIndexToItem.insert(12, pItem17); 86 | m_mapIndexToItem.insert(13, pItem27); 87 | m_mapIndexToItem.insert(14, pItem18); 88 | m_mapIndexToItem.insert(15, pItem28); 89 | 90 | connect(pItem11, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 91 | connect(pItem12, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 92 | connect(pItem13, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 93 | connect(pItem14, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 94 | connect(pItem15, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 95 | connect(pItem16, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 96 | connect(pItem17, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 97 | connect(pItem18, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 98 | 99 | connect(pItem21, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 100 | connect(pItem22, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 101 | connect(pItem23, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 102 | connect(pItem24, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 103 | connect(pItem25, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 104 | connect(pItem26, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 105 | connect(pItem27, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 106 | connect(pItem28, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &))); 107 | } 108 | 109 | void CustomColorArea::setGivenItemColor(int iIndex, const QColor &c) 110 | { 111 | BasicColorItem *pCurItem = m_mapIndexToItem[iIndex]; 112 | pCurItem->setColor(c); 113 | } 114 | -------------------------------------------------------------------------------- /ColorDialog/CustomColorArea.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/CustomColorArea.h -------------------------------------------------------------------------------- /ColorDialog/HColorArea.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "HColorArea.h" 7 | 8 | HColorArea::HColorArea(QWidget *parent) 9 | : QWidget(parent) 10 | , m_hue(0.0) 11 | , m_iHue(0) 12 | , m_iColorWidth(25) 13 | , m_iColorHeight(256) 14 | { 15 | createHuePixmap(); 16 | } 17 | 18 | HColorArea::~HColorArea() 19 | { 20 | 21 | } 22 | 23 | void HColorArea::setHue(int h) 24 | { 25 | m_hue = (double)h / 360; 26 | m_iHue = h; 27 | update(); 28 | } 29 | 30 | void HColorArea::paintEvent(QPaintEvent *) 31 | { 32 | QPainter painter(this); 33 | painter.setRenderHint(QPainter::Antialiasing); 34 | painter.drawPixmap(0, 0, m_huePixmap); 35 | 36 | int iHeight = m_iColorHeight - m_hue * m_iColorHeight; 37 | QPolygonF triangle; 38 | triangle.append(QPointF(m_iColorWidth, iHeight + topMargin)); 39 | triangle.append(QPointF(width(), iHeight)); 40 | triangle.append(QPointF(width(), iHeight + 2 * topMargin - 1)); 41 | painter.setPen(Qt::NoPen); 42 | painter.setBrush(Qt::white); 43 | painter.drawPolygon(triangle); 44 | } 45 | 46 | void HColorArea::mousePressEvent(QMouseEvent *ev) 47 | { 48 | double tempValue = 1 - (double)(ev->pos().y() - topMargin) / m_iColorHeight; 49 | m_hue = qBound(0.0, tempValue, 1.0); 50 | update(); 51 | m_iHue = m_hue * 360; 52 | emit hueChangedSignal(m_iHue); 53 | } 54 | 55 | void HColorArea::mouseMoveEvent(QMouseEvent *ev) 56 | { 57 | double tempValue = 1 - (double)(ev->pos().y() - topMargin) / m_iColorHeight; 58 | m_hue = qBound(0.0, tempValue, 1.0); 59 | update(); 60 | m_iHue = m_hue * 360; 61 | emit hueChangedSignal(m_iHue); 62 | } 63 | 64 | void HColorArea::createHuePixmap() 65 | { 66 | m_huePixmap = QPixmap(34, 270); 67 | m_huePixmap.fill(Qt::transparent); 68 | QPainter painter(&m_huePixmap); 69 | painter.setRenderHint(QPainter::Antialiasing); 70 | QLinearGradient hueGradient(0, m_iColorHeight, 0, 0); 71 | for (double i = 0; i < 1.0; i += 1.0 / 16) 72 | { 73 | hueGradient.setColorAt(i, QColor::fromHsvF(i, 1, 1, 1)); 74 | } 75 | hueGradient.setColorAt(1, QColor::fromHsvF(0, 1, 1, 1)); 76 | painter.setPen(Qt::NoPen); 77 | painter.setBrush(QBrush(hueGradient)); 78 | painter.drawRect(0, topMargin, m_iColorWidth, m_iColorHeight); 79 | } 80 | -------------------------------------------------------------------------------- /ColorDialog/HColorArea.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/HColorArea.h -------------------------------------------------------------------------------- /ColorDialog/PreviewColorArea.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "PreviewColorArea.h" 3 | 4 | PreviewColorArea::PreviewColorArea(QWidget *parent) 5 | : QWidget(parent) 6 | , m_curColor(Qt::black) 7 | , m_newColor(Qt::black) 8 | { 9 | 10 | } 11 | 12 | PreviewColorArea::~PreviewColorArea() 13 | { 14 | 15 | } 16 | 17 | void PreviewColorArea::setCurColor(const QColor &c) 18 | { 19 | m_curColor = c; 20 | repaint(); 21 | } 22 | 23 | void PreviewColorArea::setNewColor(const QColor &c) 24 | { 25 | m_newColor = c; 26 | update(); 27 | } 28 | 29 | void PreviewColorArea::paintEvent(QPaintEvent *) 30 | { 31 | QStylePainter painter(this); 32 | paint(painter, geometry()); 33 | } 34 | 35 | void PreviewColorArea::resizeEvent(QResizeEvent *) 36 | { 37 | update(); 38 | } 39 | 40 | void PreviewColorArea::paint(QPainter &painter, QRect rect) const 41 | { 42 | int iMiddleWidth = rect.width() / 2; 43 | int iHeight = rect.height(); 44 | painter.fillRect(0, 0, iMiddleWidth, iHeight, m_curColor); 45 | painter.fillRect(iMiddleWidth, 0, iMiddleWidth, iHeight, m_newColor); 46 | painter.setPen(QPen(Qt::black, 1)); 47 | painter.drawRect(0, 0, width() - 1, height() - 1); 48 | } 49 | 50 | void PreviewColorArea::svChangedSlot(int h, int s, int v) 51 | { 52 | m_newColor.setHsv(h, s, v); 53 | update(); 54 | emit svChangedSignal(h, s, v); 55 | } 56 | -------------------------------------------------------------------------------- /ColorDialog/PreviewColorArea.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/PreviewColorArea.h -------------------------------------------------------------------------------- /ColorDialog/SVColorArea.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/SVColorArea.cpp -------------------------------------------------------------------------------- /ColorDialog/SVColorArea.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/SVColorArea.h -------------------------------------------------------------------------------- /ColorDialog/data/images/button/button-h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/data/images/button/button-h.png -------------------------------------------------------------------------------- /ColorDialog/data/images/button/button-n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/data/images/button/button-n.png -------------------------------------------------------------------------------- /ColorDialog/data/images/button/button-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/data/images/button/button-s.png -------------------------------------------------------------------------------- /ColorDialog/data/images/mainui/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/data/images/mainui/bg.png -------------------------------------------------------------------------------- /ColorDialog/data/images/mainui/close-H.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/data/images/mainui/close-H.png -------------------------------------------------------------------------------- /ColorDialog/data/images/mainui/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/data/images/mainui/close.png -------------------------------------------------------------------------------- /ColorDialog/data/images/mainui/main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/data/images/mainui/main.png -------------------------------------------------------------------------------- /ColorDialog/data/images/mainui/max-H.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/data/images/mainui/max-H.png -------------------------------------------------------------------------------- /ColorDialog/data/images/mainui/max.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/data/images/mainui/max.png -------------------------------------------------------------------------------- /ColorDialog/data/images/mainui/min-H.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/data/images/mainui/min-H.png -------------------------------------------------------------------------------- /ColorDialog/data/images/mainui/min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/data/images/mainui/min.png -------------------------------------------------------------------------------- /ColorDialog/data/images/mainui/title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/data/images/mainui/title.png -------------------------------------------------------------------------------- /ColorDialog/data/ui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/ColorDialog/data/ui.png -------------------------------------------------------------------------------- /ColorDialog/main.cpp: -------------------------------------------------------------------------------- 1 | #include "colortest.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ColorTest w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /ColorDialog/readme.md: -------------------------------------------------------------------------------- 1 | ## Qt编写的颜色选取对话框 2 | -------------------------------------------------------------------------------- /DefineAndUseModule/StyleDemo/CustomControl/controls/ButtonColor.qml: -------------------------------------------------------------------------------- 1 | import QtQml 2.2 2 | 3 | QtObject 4 | { 5 | property color normalColor; 6 | property color hoverColor; 7 | property color pressColor; 8 | } 9 | -------------------------------------------------------------------------------- /DefineAndUseModule/StyleDemo/CustomControl/controls/ButtonColor.qmlc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/DefineAndUseModule/StyleDemo/CustomControl/controls/ButtonColor.qmlc -------------------------------------------------------------------------------- /DefineAndUseModule/StyleDemo/CustomControl/controls/CustomButton.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import CustomControl 1.0 3 | 4 | //按钮控件的实现 5 | Item 6 | { 7 | id: button 8 | width: 72 9 | height: 26 10 | property alias text: innerText.text //按钮上的文字 11 | property alias fontColor: innerText.color //文字颜色 12 | property int fontSize: 12 //字体大小 13 | property ButtonColor buttonStyle: CustomProperty.errorStyle 14 | readonly property color color: buttonStyle.normalColor //normal的颜色 15 | readonly property color hoverColor: buttonStyle.hoverColor //hover时的颜色 16 | readonly property color pressColor: buttonStyle.pressColor //press时的颜色 17 | property int borderRadius: 3 18 | onEnabledChanged: state = "" 19 | signal clicked 20 | 21 | //画按钮的矩形 22 | Rectangle 23 | { 24 | id: rectangleButton 25 | anchors.fill: parent 26 | radius: borderRadius 27 | color: parent.enabled ? parent.color : "grey" 28 | 29 | Text { 30 | id: innerText 31 | font.pointSize: fontSize 32 | anchors.centerIn: parent 33 | } 34 | } 35 | 36 | //不同的状态,按钮有不同的颜色 37 | states: [ 38 | State { 39 | name: "Hovering" 40 | PropertyChanges { 41 | target: rectangleButton 42 | color: hoverColor 43 | } 44 | }, 45 | State { 46 | name: "Pressed" 47 | PropertyChanges { 48 | target: rectangleButton 49 | color: pressColor 50 | } 51 | } 52 | ] 53 | 54 | //定义状态转换 55 | transitions: [ 56 | Transition { 57 | from: ""; to: "Hovering" 58 | ColorAnimation { duration: 60 } 59 | }, 60 | Transition { 61 | from: "*"; to: "Pressed" 62 | ColorAnimation { duration: 10 } 63 | } 64 | ] 65 | 66 | //响应鼠标事件 67 | MouseArea 68 | { 69 | hoverEnabled: true 70 | anchors.fill: parent 71 | onEntered: { parent.state='Hovering'; cursorShape = Qt.PointingHandCursor} 72 | onExited: { parent.state=''; cursorShape = Qt.ArrowCursor} 73 | onClicked: { parent.clicked();} 74 | onPressed: { parent.state="Pressed" } 75 | onReleased: { 76 | if (containsMouse) 77 | parent.state="Hovering"; 78 | else 79 | parent.state=""; 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /DefineAndUseModule/StyleDemo/CustomControl/controls/CustomButton.qmlc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/DefineAndUseModule/StyleDemo/CustomControl/controls/CustomButton.qmlc -------------------------------------------------------------------------------- /DefineAndUseModule/StyleDemo/CustomControl/controls/CustomProperty.qml: -------------------------------------------------------------------------------- 1 | pragma Singleton 2 | import QtQml 2.2 3 | 4 | QtObject 5 | { 6 | id: global 7 | objectName: "CustomColor" 8 | 9 | property ButtonColor errorStyle: ButtonColor{ 10 | objectName: "errorStyle" 11 | normalColor: "#da4f47" 12 | hoverColor: "#f3564d" 13 | pressColor: "#c4413a" 14 | } 15 | 16 | property ButtonColor warningStyle: ButtonColor{ 17 | objectName: "warningStyle" 18 | normalColor: "#ffffff" 19 | hoverColor: "#000000" 20 | pressColor: "#c4413a" 21 | } 22 | 23 | Component.onCompleted: { 24 | console.debug("Flat Global object was created once"); 25 | } 26 | Component.onDestruction: { 27 | console.debug("Flat Global object was destructed"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /DefineAndUseModule/StyleDemo/CustomControl/controls/CustomProperty.qmlc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/DefineAndUseModule/StyleDemo/CustomControl/controls/CustomProperty.qmlc -------------------------------------------------------------------------------- /DefineAndUseModule/StyleDemo/CustomControl/qmldir: -------------------------------------------------------------------------------- 1 | module CustomControl 2 | 3 | singleton CustomProperty 1.0 ./controls/CustomProperty.qml 4 | CustomButton 1.0 ./controls/CustomButton.qml 5 | -------------------------------------------------------------------------------- /DefineAndUseModule/StyleDemo/StyleDemo.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | 3 | QT += qml quick 4 | CONFIG += c++11 5 | 6 | SOURCES += main.cpp 7 | 8 | RESOURCES += qml.qrc 9 | 10 | # Additional import path used to resolve QML modules in Qt Creator's code model 11 | QML_IMPORT_PATH = C:/Users/kong/Documents/StyleDemo 12 | 13 | # Additional import path used to resolve QML modules just for Qt Quick Designer 14 | QML_DESIGNER_IMPORT_PATH = 15 | 16 | # The following define makes your compiler emit warnings if you use 17 | # any feature of Qt which as been marked deprecated (the exact warnings 18 | # depend on your compiler). Please consult the documentation of the 19 | # deprecated API in order to know how to port your code away from it. 20 | DEFINES += QT_DEPRECATED_WARNINGS 21 | 22 | # You can also make your code fail to compile if you use deprecated APIs. 23 | # In order to do so, uncomment the following line. 24 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 25 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 26 | 27 | # Default rules for deployment. 28 | qnx: target.path = /tmp/$${TARGET}/bin 29 | else: unix:!android: target.path = /opt/$${TARGET}/bin 30 | !isEmpty(target.path): INSTALLS += target 31 | 32 | DISTFILES += 33 | -------------------------------------------------------------------------------- /DefineAndUseModule/StyleDemo/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QGuiApplication app(argc, argv); 8 | 9 | QQmlApplicationEngine engine; 10 | for(QString path : engine.importPathList()) 11 | qDebug() << path; 12 | engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); 13 | 14 | return app.exec(); 15 | } 16 | -------------------------------------------------------------------------------- /DefineAndUseModule/StyleDemo/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.6 2 | import QtQuick.Window 2.2 3 | import CustomControl 1.0 4 | 5 | Window { 6 | visible: true 7 | width: 640 8 | height: 480 9 | title: qsTr("Hello World") 10 | 11 | CustomButton 12 | { 13 | text: "喵喵" 14 | fontColor: "white" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /DefineAndUseModule/StyleDemo/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /DefineAndUseModule/readme.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/DefineAndUseModule/readme.md -------------------------------------------------------------------------------- /HttpRequestTest/HttpRequestTest.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | 3 | QT += qml quick 4 | 5 | CONFIG += c++11 6 | 7 | SOURCES += main.cpp 8 | 9 | RESOURCES += qml.qrc 10 | 11 | # Additional import path used to resolve QML modules in Qt Creator's code model 12 | QML_IMPORT_PATH = 13 | 14 | # Additional import path used to resolve QML modules just for Qt Quick Designer 15 | QML_DESIGNER_IMPORT_PATH = 16 | 17 | # The following define makes your compiler emit warnings if you use 18 | # any feature of Qt which as been marked deprecated (the exact warnings 19 | # depend on your compiler). Please consult the documentation of the 20 | # deprecated API in order to know how to port your code away from it. 21 | DEFINES += QT_DEPRECATED_WARNINGS 22 | 23 | # You can also make your code fail to compile if you use deprecated APIs. 24 | # In order to do so, uncomment the following line. 25 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 26 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 27 | 28 | # Default rules for deployment. 29 | qnx: target.path = /tmp/$${TARGET}/bin 30 | else: unix:!android: target.path = /opt/$${TARGET}/bin 31 | !isEmpty(target.path): INSTALLS += target 32 | -------------------------------------------------------------------------------- /HttpRequestTest/HttpRequestTest.pro.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EnvironmentId 7 | {e61abb9a-4b09-4921-868c-1c74f1276754} 8 | 9 | 10 | ProjectExplorer.Project.ActiveTarget 11 | 0 12 | 13 | 14 | ProjectExplorer.Project.EditorSettings 15 | 16 | true 17 | false 18 | true 19 | 20 | Cpp 21 | 22 | CppGlobal 23 | 24 | 25 | 26 | QmlJS 27 | 28 | QmlJSGlobal 29 | 30 | 31 | 2 32 | UTF-8 33 | false 34 | 4 35 | false 36 | 80 37 | true 38 | true 39 | 1 40 | true 41 | false 42 | 0 43 | true 44 | true 45 | 0 46 | 8 47 | true 48 | 1 49 | true 50 | true 51 | true 52 | false 53 | 54 | 55 | 56 | ProjectExplorer.Project.PluginSettings 57 | 58 | 59 | 60 | ProjectExplorer.Project.Target.0 61 | 62 | Desktop Qt 5.8.0 MSVC2015 32bit 63 | Desktop Qt 5.8.0 MSVC2015 32bit 64 | qt.58.win32_msvc2015_kit 65 | 0 66 | 0 67 | 0 68 | 69 | C:/Users/kong/Documents/build-HttpRequestTest-Desktop_Qt_5_8_0_MSVC2015_32bit-Debug 70 | 71 | 72 | true 73 | qmake 74 | 75 | QtProjectManager.QMakeBuildStep 76 | true 77 | 78 | false 79 | false 80 | false 81 | 82 | 83 | true 84 | Make 85 | 86 | Qt4ProjectManager.MakeStep 87 | 88 | false 89 | 90 | 91 | 92 | 2 93 | 构建 94 | 95 | ProjectExplorer.BuildSteps.Build 96 | 97 | 98 | 99 | true 100 | Make 101 | 102 | Qt4ProjectManager.MakeStep 103 | 104 | true 105 | clean 106 | 107 | 108 | 1 109 | 清理 110 | 111 | ProjectExplorer.BuildSteps.Clean 112 | 113 | 2 114 | false 115 | 116 | Debug 117 | 118 | Qt4ProjectManager.Qt4BuildConfiguration 119 | 2 120 | true 121 | 122 | 123 | C:/Users/kong/Documents/build-HttpRequestTest-Desktop_Qt_5_8_0_MSVC2015_32bit-Release 124 | 125 | 126 | true 127 | qmake 128 | 129 | QtProjectManager.QMakeBuildStep 130 | false 131 | 132 | false 133 | false 134 | false 135 | 136 | 137 | true 138 | Make 139 | 140 | Qt4ProjectManager.MakeStep 141 | 142 | false 143 | 144 | 145 | 146 | 2 147 | 构建 148 | 149 | ProjectExplorer.BuildSteps.Build 150 | 151 | 152 | 153 | true 154 | Make 155 | 156 | Qt4ProjectManager.MakeStep 157 | 158 | true 159 | clean 160 | 161 | 162 | 1 163 | 清理 164 | 165 | ProjectExplorer.BuildSteps.Clean 166 | 167 | 2 168 | false 169 | 170 | Release 171 | 172 | Qt4ProjectManager.Qt4BuildConfiguration 173 | 0 174 | true 175 | 176 | 177 | C:/Users/kong/Documents/build-HttpRequestTest-Desktop_Qt_5_8_0_MSVC2015_32bit-Profile 178 | 179 | 180 | true 181 | qmake 182 | 183 | QtProjectManager.QMakeBuildStep 184 | true 185 | 186 | false 187 | true 188 | false 189 | 190 | 191 | true 192 | Make 193 | 194 | Qt4ProjectManager.MakeStep 195 | 196 | false 197 | 198 | 199 | 200 | 2 201 | 构建 202 | 203 | ProjectExplorer.BuildSteps.Build 204 | 205 | 206 | 207 | true 208 | Make 209 | 210 | Qt4ProjectManager.MakeStep 211 | 212 | true 213 | clean 214 | 215 | 216 | 1 217 | 清理 218 | 219 | ProjectExplorer.BuildSteps.Clean 220 | 221 | 2 222 | false 223 | 224 | Profile 225 | 226 | Qt4ProjectManager.Qt4BuildConfiguration 227 | 0 228 | true 229 | 230 | 3 231 | 232 | 233 | 0 234 | 部署 235 | 236 | ProjectExplorer.BuildSteps.Deploy 237 | 238 | 1 239 | 在本地部署 240 | 241 | ProjectExplorer.DefaultDeployConfiguration 242 | 243 | 1 244 | 245 | 246 | false 247 | false 248 | 1000 249 | 250 | true 251 | 252 | false 253 | false 254 | false 255 | false 256 | true 257 | 0.01 258 | 10 259 | true 260 | 1 261 | 25 262 | 263 | 1 264 | true 265 | false 266 | true 267 | valgrind 268 | 269 | 0 270 | 1 271 | 2 272 | 3 273 | 4 274 | 5 275 | 6 276 | 7 277 | 8 278 | 9 279 | 10 280 | 11 281 | 12 282 | 13 283 | 14 284 | 285 | -1 286 | 287 | 288 | 289 | %{buildDir} 290 | Custom Executable 291 | 292 | ProjectExplorer.CustomExecutableRunConfiguration 293 | 3768 294 | false 295 | true 296 | false 297 | false 298 | true 299 | 300 | 1 301 | 302 | 303 | 304 | ProjectExplorer.Project.TargetCount 305 | 1 306 | 307 | 308 | ProjectExplorer.Project.Updater.FileVersion 309 | 18 310 | 311 | 312 | Version 313 | 18 314 | 315 | 316 | -------------------------------------------------------------------------------- /HttpRequestTest/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QGuiApplication app(argc, argv); 7 | 8 | QQmlApplicationEngine engine; 9 | engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); 10 | 11 | return app.exec(); 12 | } 13 | -------------------------------------------------------------------------------- /HttpRequestTest/main.qml: -------------------------------------------------------------------------------- 1 | /* 2 | QML使用XMLHttpRequest的例子 3 | 使用豆瓣电影的接口作为例子 4 | 比如https://api.douban.com/v2/movie/search?q=十里桃花 5 | 对搜索返回文本的解析,其实就是使用js解析json 6 | */ 7 | 8 | import QtQuick 2.5 9 | import QtQuick.Controls 1.4 10 | 11 | ApplicationWindow { 12 | visible: true 13 | width: 340 14 | height: 180 15 | title: qsTr("网络请求测试") 16 | 17 | Row 18 | { 19 | width: parent.width 20 | TextField 21 | { 22 | id: textField 23 | placeholderText: "输入电影/电视剧名称" 24 | } 25 | 26 | Button 27 | { 28 | id: searchBtn 29 | text: "搜索电影" 30 | 31 | onClicked: 32 | { 33 | var doc = new XMLHttpRequest(); 34 | doc.onreadystatechange = function() { 35 | if (doc.readyState == XMLHttpRequest.DONE) { 36 | var a = JSON.parse(doc.responseText) 37 | var b = a.subjects //subjects结点值为电影内容 38 | if(b.length == 0) 39 | { 40 | console.log("搜索结果为空") 41 | return 42 | } 43 | 44 | for(var i = 0; i < b.length; ++i) 45 | { 46 | console.log(b[i].title) //打印电影的名称 47 | } 48 | } 49 | } 50 | var baseStr = "https://api.douban.com/v2/movie/search?q=" 51 | baseStr += textField.text 52 | doc.open("GET", baseStr); //设置参数然后发出请求 53 | doc.send(); 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /HttpRequestTest/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /HttpRequestTest/readme.md: -------------------------------------------------------------------------------- 1 | QML网络请求的例子 -------------------------------------------------------------------------------- /MessagBox/README.md: -------------------------------------------------------------------------------- 1 | # Qt_MessageBox 2 | 3 | ## 程序说明 4 | 消息对话框 5 | 界面基本样式如下:
6 | ![](image/demo.png) 7 | 8 | ## 使用示例 9 | ```c++ 10 | SimpleMsgBox::ButtonRole role = SimpleMsgBox::warning(this, "删除", "确定删除?"); 11 | if (role = SimpleMsgBox::Yes) 12 | { 13 | //确定后的相关操作 14 | } 15 | else 16 | { 17 | //取消后的相关操作 18 | } 19 | ``` 20 | -------------------------------------------------------------------------------- /MessagBox/SimpleMsgBox.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/MessagBox/SimpleMsgBox.cpp -------------------------------------------------------------------------------- /MessagBox/SimpleMsgBox.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/MessagBox/SimpleMsgBox.h -------------------------------------------------------------------------------- /MessagBox/SimpleMsgBox.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | SimpleMsgBox 4 | 5 | 6 | 7 | 0 8 | 0 9 | 281 10 | 127 11 | 12 | 13 | 14 | SimpleMsgBox 15 | 16 | 17 | /*主界面样式表*/ 18 | QWidget 19 | { 20 | border:none; 21 | color:white; 22 | font-family:微软雅黑; 23 | font-size:14px; 24 | outline:0 px; 25 | background:transparent; 26 | } 27 | 28 | #topWgt{border-image:url(image/top.png) 2;border-width:2;} 29 | #closeBtn{border-image:url(image/close.png) 2;border-width:2;} 30 | #bgWgt{border-image:url(image/bg.png) 2;border-width:2;} 31 | #iconLbl{border-image:url(image/notice.png) 2;border-width:2;} 32 | /*1-按钮开始*/ 33 | QPushButton 34 | { 35 | border:none; 36 | border-image:url(F:/data/images/button/button-n.png) 3; 37 | border-width:3; 38 | } 39 | QPushButton:hover 40 | { 41 | border-image:url(F:/data/images/button/button-h.png) 3; 42 | border-width:3; 43 | } 44 | QPushButton:pressed 45 | { 46 | border-image:url(F:/data/images/button/button-s.png) 3; 47 | border-width:3; 48 | } 49 | /*1-按钮结束*/ 50 | 51 | 52 | 53 | 0 54 | 55 | 56 | 0 57 | 58 | 59 | 0 60 | 61 | 62 | 0 63 | 64 | 65 | 0 66 | 67 | 68 | 69 | 70 | 71 | 0 72 | 32 73 | 74 | 75 | 76 | 77 | 16777215 78 | 32 79 | 80 | 81 | 82 | 83 | 10 84 | 85 | 86 | 0 87 | 88 | 89 | 4 90 | 91 | 92 | 0 93 | 94 | 95 | 96 | 97 | 98 | 0 99 | 32 100 | 101 | 102 | 103 | 104 | 16777215 105 | 32 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | Qt::Horizontal 117 | 118 | 119 | 120 | 248 121 | 20 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 22 131 | 30 132 | 133 | 134 | 135 | 136 | 22 137 | 30 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 4 153 | 154 | 155 | 6 156 | 157 | 158 | 4 159 | 160 | 161 | 6 162 | 163 | 164 | 9 165 | 166 | 167 | 168 | 169 | 170 | 171 | Qt::Horizontal 172 | 173 | 174 | 175 | 24 176 | 17 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 36 186 | 36 187 | 188 | 189 | 190 | 191 | 36 192 | 36 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 66 205 | 26 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | Qt::Horizontal 217 | 218 | 219 | 220 | 25 221 | 17 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 24 232 | 233 | 234 | 235 | 236 | Qt::Horizontal 237 | 238 | 239 | 240 | 27 241 | 20 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 66 251 | 26 252 | 253 | 254 | 255 | 256 | 66 257 | 26 258 | 259 | 260 | 261 | 确定 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 66 270 | 26 271 | 272 | 273 | 274 | 275 | 66 276 | 26 277 | 278 | 279 | 280 | 取消 281 | 282 | 283 | 284 | 285 | 286 | 287 | Qt::Horizontal 288 | 289 | 290 | 291 | 28 292 | 20 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | -------------------------------------------------------------------------------- /MessagBox/image/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/MessagBox/image/bg.png -------------------------------------------------------------------------------- /MessagBox/image/close - 副本.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/MessagBox/image/close - 副本.png -------------------------------------------------------------------------------- /MessagBox/image/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/MessagBox/image/close.png -------------------------------------------------------------------------------- /MessagBox/image/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/MessagBox/image/demo.png -------------------------------------------------------------------------------- /MessagBox/image/notice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/MessagBox/image/notice.png -------------------------------------------------------------------------------- /MessagBox/image/top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/MessagBox/image/top.png -------------------------------------------------------------------------------- /QThreadTest/GetPostThread.py: -------------------------------------------------------------------------------- 1 | import json 2 | import requests 3 | from PyQt5.QtCore import QThread 4 | from PyQt5.QtCore import pyqtSignal 5 | 6 | 7 | class GetPostThread(QThread): 8 | postSignal = pyqtSignal(str) 9 | 10 | agent = 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.8 Safari/537.36' 11 | headers = { 12 | 'User-Agent': agent 13 | } 14 | 15 | def __init__(self): 16 | QThread.__init__(self) 17 | self.subreddits = [] 18 | 19 | def __del__(self): 20 | self.wait() 21 | 22 | def setSubReddit(self, subReddit): 23 | self.subreddits = subReddit 24 | 25 | def _get_top_post(self, subreddit): 26 | url = "https://www.reddit.com/r/{}.json?limit=1".format(subreddit) 27 | print(url) 28 | try: 29 | restext = requests.get(url, headers=self.headers) 30 | data = json.loads(restext.text) 31 | top_post = data['data']['children'][0]['data'] 32 | except Exception as e: 33 | print(e) 34 | return '错误数据' 35 | return "'{title}' by {author} in {subreddit}".format(**top_post) 36 | 37 | def run(self): 38 | for subreddit in self.subreddits: 39 | top_post = self._get_top_post(subreddit) 40 | self.postSignal.emit(top_post) 41 | self.sleep(2) -------------------------------------------------------------------------------- /QThreadTest/SingleThreadTest.py: -------------------------------------------------------------------------------- 1 | import json 2 | import sys 3 | import time 4 | import requests 5 | from PyQt5 import QtWidgets 6 | from PyQt5.QtWidgets import * 7 | 8 | 9 | class ThreadTestUI(QWidget): 10 | agent = 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.8 Safari/537.36' 11 | headers = { 12 | 'User-Agent': agent 13 | } 14 | 15 | def __init__(self, parent = None): 16 | super().__init__(parent) 17 | self.initUI() 18 | #建立信号槽连接 19 | self.startBtn.clicked.connect(self.startBtnClicked) 20 | 21 | def initUI(self): 22 | #初始化界面控件 23 | self.setWindowTitle('QThread Study') 24 | 25 | keywordLbl = QLabel('关键字(以逗号,隔开):') 26 | self.keywordEdit = QLineEdit() 27 | hrLayout = QHBoxLayout() 28 | hrLayout.addWidget(keywordLbl) 29 | hrLayout.addWidget(self.keywordEdit) 30 | 31 | resultLbl = QLabel('搜索结果:') 32 | self.resultList = QListWidget() 33 | vrLayout = QVBoxLayout() 34 | vrLayout.addWidget(resultLbl) 35 | vrLayout.addWidget(self.resultList) 36 | 37 | self.searchProgBar = QProgressBar() 38 | self.searchProgBar.setValue(0) 39 | self.stopBtn = QPushButton('停止') 40 | self.stopBtn.setEnabled(False) 41 | self.startBtn = QPushButton('开始') 42 | hrLayout1 = QHBoxLayout() 43 | hrLayout1.addWidget(self.stopBtn) 44 | hrLayout1.addWidget(self.startBtn) 45 | 46 | vrLayout1 = QVBoxLayout(self) 47 | vrLayout1.addLayout(hrLayout) 48 | vrLayout1.addLayout(vrLayout) 49 | vrLayout1.addWidget(self.searchProgBar) 50 | vrLayout1.addLayout(hrLayout1) 51 | 52 | def startBtnClicked(self): 53 | subreddit_list = str(self.keywordEdit.text()).split(',') 54 | if subreddit_list == ['']: 55 | print('没有搜索内容') 56 | return 57 | self.resultList.clear() 58 | for post in self.get_top_from_subreddits(subreddit_list): 59 | self.resultList.addItem(post) 60 | 61 | 62 | def get_top_post(self,subreddit): 63 | #从服务器获取数据 64 | url = "https://www.reddit.com/r/{}.json?limit=1".format(subreddit) 65 | try: 66 | restext = requests.get(url, headers=self.headers) 67 | data = json.loads(restext.text) 68 | top_post = data['data']['children'][0]['data'] 69 | except Exception as e: 70 | print(e) 71 | return '错误数据' 72 | return "'{title}' by {author} in {subreddit}".format(**top_post) 73 | 74 | def get_top_from_subreddits(self,subreddits): 75 | for subreddit in subreddits: 76 | yield self.get_top_post(subreddit) 77 | time.sleep(2) 78 | 79 | if __name__ == '__main__': 80 | app = QtWidgets.QApplication(sys.argv) 81 | threadTestUi = ThreadTestUI() 82 | threadTestUi.show() 83 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /QThreadTest/ThreadTestUI.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtWidgets import * 4 | from GetPostThread import GetPostThread 5 | 6 | 7 | class ThreadTestUI(QWidget): 8 | def __init__(self, parent = None): 9 | super().__init__(parent) 10 | self.initUI() 11 | self.testThread = GetPostThread() 12 | 13 | #建立信号槽连接 14 | self.startBtn.clicked.connect(self.startBtnClicked) 15 | self.stopBtn.clicked.connect(self.stopBtnClicked) 16 | self.testThread.finished.connect(self.threadFinished) 17 | self.testThread.postSignal.connect(self.getPostSlot) 18 | 19 | def initUI(self): 20 | self.setWindowTitle('QThread Study') 21 | 22 | keywordLbl = QLabel('关键字(以逗号,隔开):') 23 | self.keywordEdit = QLineEdit() 24 | hrLayout = QHBoxLayout() 25 | hrLayout.addWidget(keywordLbl) 26 | hrLayout.addWidget(self.keywordEdit) 27 | 28 | resultLbl = QLabel('搜索结果:') 29 | self.resultList = QListWidget() 30 | vrLayout = QVBoxLayout() 31 | vrLayout.addWidget(resultLbl) 32 | vrLayout.addWidget(self.resultList) 33 | 34 | self.searchProgBar = QProgressBar() 35 | self.searchProgBar.setValue(0) 36 | self.stopBtn = QPushButton('停止') 37 | self.stopBtn.setEnabled(False) 38 | self.startBtn = QPushButton('开始') 39 | hrLayout1 = QHBoxLayout() 40 | hrLayout1.addWidget(self.stopBtn) 41 | hrLayout1.addWidget(self.startBtn) 42 | 43 | vrLayout1 = QVBoxLayout(self) 44 | vrLayout1.addLayout(hrLayout) 45 | vrLayout1.addLayout(vrLayout) 46 | vrLayout1.addWidget(self.searchProgBar) 47 | vrLayout1.addLayout(hrLayout1) 48 | 49 | def startBtnClicked(self): 50 | subreddit_list = str(self.keywordEdit.text()).split(',') 51 | if subreddit_list == ['']: 52 | print('没有搜索内容') 53 | return 54 | self.resultList.clear() 55 | count = len(subreddit_list) 56 | self.searchProgBar.setMaximum(count) 57 | self.testThread.setSubReddit(subreddit_list) 58 | self.testThread.start() 59 | self.startBtn.setEnabled(False) 60 | self.stopBtn.setEnabled(True) 61 | 62 | def stopBtnClicked(self): 63 | self.testThread.terminate() 64 | 65 | def threadFinished(self): 66 | self.stopBtn.setEnabled(False) 67 | self.startBtn.setEnabled(True) 68 | self.searchProgBar.setValue(0) 69 | print('获取结束') 70 | 71 | def getPostSlot(self, top_post): 72 | print(top_post) 73 | self.resultList.addItem(top_post) 74 | self.searchProgBar.setValue(self.searchProgBar.value() + 1) 75 | 76 | if __name__ == '__main__': 77 | app = QtWidgets.QApplication(sys.argv) 78 | threadTestUi = ThreadTestUI() 79 | threadTestUi.show() 80 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /QThreadTest/readme.md: -------------------------------------------------------------------------------- 1 | ##QThread的简单使用 2 | 运行程序需要python3、Pyqt5、requests库 -------------------------------------------------------------------------------- /SgsClub/Control/Config.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | #基本链接 4 | baseurl = "http://club.sanguosha.com/" 5 | #登录接口 6 | loginurl = "http://club.sanguosha.com/member.php?mod=logging&action=login&plat=sdo" 7 | #检测是否登录成功 8 | ckurl = "http://club.sanguosha.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&inajax=1" 9 | #发帖回帖所需的hash码 10 | formhash = "" 11 | # 12 | session = requests.session() 13 | 14 | agent = 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.8 Safari/537.36' 15 | headers = { 16 | 'User-Agent': agent, 17 | 'Host': "club.sanguosha.com", 18 | "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", 19 | "Accept-Encoding": "gzip, deflate", 20 | "Accept-Language": "zh-CN,zh;q=0.8,en;q=0.6", 21 | "Content-Type": "application/x-www-form-urlencoded" 22 | } 23 | 24 | broHeaders = { 25 | 'User-Agent': agent, 26 | 'Host': "club.sanguosha.com", 27 | "Content-Type": "application/x-www-form-urlencoded" 28 | } -------------------------------------------------------------------------------- /SgsClub/Control/HomePageThread.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtCore import QThread 2 | from bs4 import BeautifulSoup 3 | from PyQt5.QtCore import pyqtSignal 4 | 5 | class HomePageThread(QThread): 6 | postDataSignal = pyqtSignal(list, list) 7 | agent = 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.8 Mobile Safari/537.36' 8 | baseUrl = "http://club.sanguosha.com/" 9 | headers = { 10 | 'Connection':'keep-alive', 11 | 'Host': 'club.sanguosha.com', 12 | 'User-Agent': agent, 13 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 14 | 'Accept-Encoding': 'gzip, deflate, sdch', 15 | 'Accept-Language': 'zh-CN,zh;q=0.8,en;q=0.6' 16 | } 17 | 18 | 19 | def __init__(self, parent=None): 20 | super().__init__(parent) 21 | import requests 22 | self.rt = requests.session() 23 | 24 | def __del__(self): 25 | self.wait() 26 | 27 | def run(self): 28 | topList = [] #置顶帖子 29 | downList = [] #未指定帖子 30 | r = self.rt.get(self.baseUrl, headers=self.headers) 31 | soup = BeautifulSoup(r.text, 'lxml') 32 | 33 | #获取置顶帖子内容 34 | for post in soup.find_all(class_='tl_top'): 35 | titleSoup = post.find('a') 36 | if titleSoup: 37 | topPost = {} 38 | topPost['link'] = titleSoup['href'] 39 | topPost['style'] = titleSoup['style'] 40 | topPost['title'] = titleSoup.string.strip() 41 | topList.append(topPost) 42 | 43 | #获取未置顶帖子 44 | for post in soup.find_all(class_='tl_shadow'): 45 | titleSoup = post.find('a') 46 | if titleSoup: 47 | downPost = {} 48 | downPost['link'] = post.find(class_='ti_item')['href'] 49 | downPost['author'] = post.find(class_='ti_author').text 50 | downPost['title'] = post.find(class_='ti_title').text.strip() 51 | downPost['summary'] = post.find(class_='ti_abs').text 52 | downPost['time'] = post.find(class_='ti_time').text 53 | downPost['replynum'] = post.find(class_='btn_icon').text 54 | downList.append(downPost) 55 | 56 | self.postDataSignal.emit(topList, downList) -------------------------------------------------------------------------------- /SgsClub/Control/LoginThread.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtCore import QThread 2 | from bs4 import BeautifulSoup 3 | from PyQt5.QtCore import pyqtSignal 4 | 5 | class LoginThread(QThread): 6 | def __init__(self, parent=None): 7 | super().__init__(parent) 8 | 9 | def __del__(self): 10 | self.wait() 11 | 12 | def run(self): 13 | pass 14 | -------------------------------------------------------------------------------- /SgsClub/Control/PostPageThread.py: -------------------------------------------------------------------------------- 1 | import re 2 | import requests 3 | from PyQt5.QtCore import QThread 4 | from bs4 import BeautifulSoup 5 | from PyQt5.QtCore import pyqtSignal 6 | 7 | 8 | class PostPageThread(QThread): 9 | postDataSignal = pyqtSignal(str,list) 10 | agent = 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.8 Mobile Safari/537.36' 11 | baseUrl = "http://club.sanguosha.com/" 12 | postlink = baseUrl 13 | headers = { 14 | 'Connection':'keep-alive', 15 | 'Host': 'club.sanguosha.com', 16 | 'User-Agent': agent, 17 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 18 | 'Accept-Encoding': 'gzip, deflate, sdch', 19 | 'Accept-Language': 'zh-CN,zh;q=0.8,en;q=0.6' 20 | } 21 | 22 | 23 | def __init__(self, parent = None): 24 | QThread.__init__(self, parent) 25 | self.rt = requests.session() 26 | 27 | def __del__(self): 28 | self.wait() 29 | 30 | def getPostContent(self): 31 | msgList = [] 32 | r = self.rt.get(self.postlink, headers=self.headers) 33 | #print(r.text) 34 | soup = BeautifulSoup(r.text, 'lxml') #声明BeautifulSoup对象 35 | for replyContent in soup.find_all(class_='plc cl'): 36 | if replyContent.find(class_='display pi'): 37 | reply = {} 38 | reply['avatar'] = replyContent.find(class_='avatar').img['src'] 39 | reply['author']=replyContent.find(class_='blue').get_text() 40 | reply['message']=replyContent.find(class_='message') 41 | msgList.append(reply) 42 | #print(reply) 43 | #print(22) 44 | self.postDataSignal.emit(self.postid,msgList) 45 | 46 | def run(self): 47 | self.getPostContent() 48 | 49 | #设置帖子链接 50 | def setPostLink(self, link): 51 | self.postlink = self.baseUrl + link.replace('amp;','') 52 | postrow = re.findall(r'tid=(.*?)&', link) 53 | if len(postrow) != 0: 54 | self.postid = postrow[0] 55 | print(self.postlink) 56 | print(self.postid) 57 | 58 | if __name__ == '__main__': 59 | rr = PostPageThread() 60 | rr.start() -------------------------------------------------------------------------------- /SgsClub/Control/SgsClub.py: -------------------------------------------------------------------------------- 1 | import requests, time, urllib.parse, re, json 2 | 3 | class SgsClub: 4 | def __init__(self): 5 | self.baseurl = "http://club.sanguosha.com/" 6 | self.loginurl = "http://club.sanguosha.com/member.php?mod=logging&action=login&plat=sdo" 7 | self.ckurl = "http://club.sanguosha.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&inajax=1" 8 | self.formhash = "" 9 | self.session = requests.session() 10 | 11 | agent = 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.8 Safari/537.36' 12 | self.headers = { 13 | 'User-Agent': agent, 14 | 'Host': "club.sanguosha.com", 15 | "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", 16 | "Accept-Encoding": "gzip, deflate", 17 | "Accept-Language": "zh-CN,zh;q=0.8,en;q=0.6", 18 | "Content-Type": "application/x-www-form-urlencoded" 19 | } 20 | 21 | self.broHeaders = { 22 | 'User-Agent': agent, 23 | 'Host': "club.sanguosha.com", 24 | "Content-Type": "application/x-www-form-urlencoded" 25 | } 26 | 27 | def loginClub(self, usrname, pwd): 28 | self.username = usrname 29 | self.password = pwd 30 | 31 | try: 32 | self._getCookies() 33 | except IOError as e: 34 | print(e) 35 | 36 | if self._isLogin(): 37 | print("登录成功") 38 | else: 39 | self.session.cookies.clear() 40 | self.loginold() 41 | 42 | def login(self): 43 | ''' 44 | 功能:登录 45 | 返回值:False表示登录失败,由于网络超时、获取ticket失败等原因 46 | True表示登录成功 47 | ''' 48 | #第一步:获取登录所需的ticket 49 | #发出网络请求 50 | urlPreLogin = 'http://cas.dobest.com/authen/staticLogin.jsonp' 51 | payloadPreLogin = {'inputUserId':self.username,'password':self.password,'appId':'205','areaId':'1'} 52 | try: 53 | resultPreLogin = self.session.get(urlPreLogin, params=payloadPreLogin).text 54 | except Exception as e: 55 | print(e) 56 | return False 57 | 58 | #解析返回值,获得ticket 59 | try: 60 | resultDict = eval(resultPreLogin[resultPreLogin.index('(') + 1: resultPreLogin.index(')')]) 61 | print(resultDict) 62 | returnCode = resultDict['return_code'] 63 | if(returnCode < 0): 64 | print("请求失败") 65 | return False 66 | #获取动态生成的ticket 67 | ticket = resultDict['data']['ticket'] 68 | except Exception as e: 69 | print(e) 70 | return False 71 | print("ticket:" + ticket) 72 | 73 | #第二步:根据ticket进行登录 74 | urlLogin = 'http://club.sanguosha.com/member.php' 75 | payloadLogin = {'mod':'logging', 'action':'login','plat':'sdo', 'rurl':self.baseurl,'ticket':ticket} 76 | try: 77 | self.session.get(urlLogin, params=payloadLogin) 78 | except Exception as e: 79 | print(e) 80 | return False 81 | print('登录成功') 82 | #登录成功后,将cookie保存起来,用于下次登录 83 | with open('cookie.json', 'w') as f: 84 | json.dump(self.session.cookies.get_dict(), f) 85 | return True 86 | 87 | def loginold(self): 88 | ''' 89 | 功能:登录(可能由于以前注册的号与现在注册的号有区别,所以需要传更多参数) 90 | ''' 91 | #第一步:获取ticket 92 | urlPreLogin = 'http://cas.dobest.com/authen/staticLogin.jsonp' 93 | payloadPreLogin = urllib.parse.urlencode({'inputUserId':self.username,'password':self.password,'appId':'205','areaId':'1','authenSource':'2','productId':'2','autoLoginFlag':'0','serviceUrl':self.loginurl}) 94 | try: 95 | resultPreLogin = self.session.get(urlPreLogin, params=payloadPreLogin).text 96 | except Exception as e: 97 | print(e) 98 | return False 99 | 100 | #解析返回值,获得ticket 101 | try: 102 | resultDict = eval(resultPreLogin[resultPreLogin.index('(') + 1: resultPreLogin.index(')')]) 103 | print(resultDict) 104 | returnCode = resultDict['return_code'] 105 | if(returnCode < 0): 106 | print("请求失败")#可能是用户名或密码错误,或者是请求参数有误 107 | return False 108 | #动态生成的ticket 109 | ticket = resultDict['data']['ticket'] 110 | except Exception as e: 111 | print(e) 112 | return False 113 | print("ticket:" + ticket) 114 | 115 | #第二步:根据ticket进行登录 116 | urlLogin = 'http://club.sanguosha.com/member.php' 117 | payloadLogin = {'mod':'logging', 'action':'login', 'plat':'sdo', 'rurl':self.baseurl, 'ticket':ticket} 118 | try: 119 | self.session.get(urlLogin, params=payloadLogin) 120 | except Exception as e: 121 | print(e) 122 | return False 123 | 124 | print('登录成功') 125 | #登录成功后,将cookie保存起来,用于下次登录 126 | with open('cookie.json', 'w') as f: 127 | json.dump(self.session.cookies.get_dict(), f) 128 | return True 129 | 130 | def setFormhash(self): 131 | ''' 132 | 功能:设置formhash 133 | 该参数在发帖和回帖时会用到 134 | 返回值:-1表示获取失败,-1表示成功获取并设置formhash 135 | ''' 136 | moodInterface = "http://club.sanguosha.com/plugin.php?id=dsu_paulsign:sign" 137 | try: 138 | moodResponce = self.session.get(moodInterface) 139 | except Exception as e: 140 | print(e) 141 | return -1 142 | #print(moodResponce.text) 143 | formhashs = re.findall(r'formhash=(.*?)&', moodResponce.text) 144 | if len(formhashs) != 0: 145 | self.formhash = formhashs[0] 146 | print("formhash是:" + self.formhash) 147 | return 1 148 | else: 149 | print("没有找到formhash") 150 | return -1 151 | 152 | def reply(self, fid, tid, replytext): 153 | ''' 154 | 功能:回帖 155 | 版块id:param fid: 156 | 帖子id:param tid: 157 | 回复的文本:param replytext: 158 | :return: 159 | ''' 160 | replyInterface = "http://club.sanguosha.com/forum.php?mod=post&action=reply&fid={}&tid={}&extra=page%3D1&replysubmit=yes&infloat=yes&handlekey=fastpost&inajax=1".format(fid, tid) 161 | try: 162 | payloadReply = urllib.parse.urlencode({'fid':fid,'formhash':self.formhash, 'usesig':'1','posttime':int(time.time()),'message':replytext,'subject':''}) 163 | except Exception as e: 164 | print(e) 165 | return False 166 | responceReply = self.session.post(replyInterface, data=payloadReply, headers=self.headers) 167 | print("回帖成功") 168 | return True 169 | 170 | def sign(self): 171 | ''' 172 | 功能:签到 173 | 返回值:-1表示签到失败,0表示已经签到,1表示签到成功,-2表示未登录 174 | ''' 175 | signInterface = "http://club.sanguosha.com/plugin.php?id=dsu_paulsign:sign_sgs&operation=qiandao&infloat=1&inajax=1" 176 | try: 177 | r = self.session.get(signInterface, headers=self.broHeaders) 178 | except Exception as e: 179 | print(e) 180 | return -1 181 | if("签到成功" in r.text): 182 | print("签到成功") 183 | return 1 184 | elif("已经签到" in r.text): 185 | print("您已经签过到了") 186 | return 0 187 | elif("需要先登录" in r.text): 188 | print("未登录") 189 | return -2 190 | print("签到失败") 191 | return -1 192 | 193 | def sendpost(self, fid, subject, posttext): 194 | ''' 195 | 功能:发帖 196 | :param fid: 197 | :param subject: 198 | :param posttext: 199 | :return: 200 | ''' 201 | postInterface = "http://club.sanguosha.com/forum.php?mod=post&action=newthread&fid={}&extra=&topicsubmit=yes".format(fid) 202 | payloadPost = urllib.parse.urlencode({'formhash': self.formhash, 'message': posttext, 'subject': subject, 'posttime':int(time.time()), 'addfeed':'1', 'allownoticeauthor':'1', 'checkbox':'0', 'newalbum':'', 'readperm':'', 'rewardfloor':'', 'rushreplyfrom':'', 'rushreplyto':'', 'save':'', 'stopfloor':'', 'typeid':'', 'uploadalbum':'', 'usesig':'1', 'wysiwyg':'0' }) 203 | responceReply = self.session.post(postInterface, data=payloadPost, headers=self.broHeaders) 204 | print(responceReply.text) 205 | 206 | def _getCookies(self): 207 | """ 208 | 功能:获取本地存储的cookies 209 | """ 210 | with open('cookie.json') as f: 211 | cookies = json.load(f) 212 | self.session.cookies.update(cookies) 213 | 214 | def _isLogin(self): 215 | ''' 216 | 功能:判断是否已经登录 217 | :return: 218 | ''' 219 | r = self.session.get(self.ckurl) 220 | match = re.search(u'欢迎您回来', r.text) 221 | if match: 222 | print("1") 223 | return True 224 | print("2") 225 | return False 226 | 227 | 228 | def sign2(self,msg = u'约吗?'): 229 | ''' 签到 ''' 230 | url = 'http://club.sanguosha.com/plugin.php?id=dsu_paulsign:sign_sgs&operation=qiandao&infloat=1&inajax=1' 231 | postData = urllib.parse.urlencode({'fastreply': '1', 'formhash': self.formhash, 'qdmode': '1', 'qdxq': '哈哈', 'todaysay':msg.encode('gbk') }) 232 | r = self.session.post(url, data=postData) 233 | print(r.text) 234 | 235 | 236 | 237 | if __name__ == '__main__': 238 | sgsClub = SgsClub('your username', 'your password') 239 | sgsClub.setFormhash() 240 | sgsClub.sign2() 241 | 242 | #sgsClub.login() 243 | #sgsClub.setFormhash() 244 | #sgsClub.reply(59, 201390, '就在前几页。。') 245 | #sgsClub.sign() 246 | -------------------------------------------------------------------------------- /SgsClub/Control/__pycache__/HomePageThread.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/Control/__pycache__/HomePageThread.cpython-35.pyc -------------------------------------------------------------------------------- /SgsClub/Control/__pycache__/PostPageThread.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/Control/__pycache__/PostPageThread.cpython-35.pyc -------------------------------------------------------------------------------- /SgsClub/Control/__pycache__/SgsClub.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/Control/__pycache__/SgsClub.cpython-35.pyc -------------------------------------------------------------------------------- /SgsClub/Control/test.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from PyQt5.QtCore import QThread 3 | from PyQt5.QtCore import pyqtSignal 4 | from bs4 import BeautifulSoup 5 | 6 | agent = 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.8 Mobile Safari/537.36' 7 | baseUrl = "http://club.sanguosha.com/" 8 | headers = { 9 | 'Connection':'keep-alive', 10 | 'Host': 'club.sanguosha.com', 11 | 'User-Agent': agent, 12 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 13 | 'Accept-Encoding': 'gzip, deflate, sdch', 14 | 'Accept-Language': 'zh-CN,zh;q=0.8,en;q=0.6' 15 | } 16 | 17 | r = requests.get(baseUrl, headers=headers) 18 | 19 | topList = [] #置顶帖子 20 | downList = [] #未指定帖子 21 | 22 | #print(r.text) 23 | soup = BeautifulSoup(r.text, 'lxml') 24 | for post in soup.find_all(class_='tl_top'): 25 | titleSoup = post.find('a') 26 | if titleSoup: 27 | pass 28 | #print(titleSoup['href']) 29 | #print(titleSoup['style']) 30 | #print(titleSoup.string) 31 | 32 | #获取未置顶帖子 33 | for post in soup.find_all(class_='tl_shadow'): 34 | downPost = {} 35 | downPost['link'] = post.find('a')['href'] 36 | downPost['author'] = post.find(class_='ti_author').text 37 | downPost['title'] = post.find(class_='ti_title').text.strip() 38 | downPost['summary'] = post.find(class_='ti_abs').text 39 | downList.append(downPost) 40 | 41 | print(downList) -------------------------------------------------------------------------------- /SgsClub/Control/test1.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from PyQt5.QtCore import QThread 3 | from PyQt5.QtCore import pyqtSignal 4 | from bs4 import BeautifulSoup 5 | 6 | agent = 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.8 Mobile Safari/537.36' 7 | baseUrl = "http://club.sanguosha.com/forum.php?mod=viewthread&tid=206633&page=1&mobile=2" 8 | headers = { 9 | 'Connection':'keep-alive', 10 | 'Host': 'club.sanguosha.com', 11 | 'User-Agent': agent, 12 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 13 | 'Accept-Encoding': 'gzip, deflate, sdch', 14 | 'Accept-Language': 'zh-CN,zh;q=0.8,en;q=0.6' 15 | } 16 | 17 | r = requests.get(baseUrl, headers=headers) 18 | 19 | msgList = [] 20 | 21 | soup = BeautifulSoup(r.text, 'lxml') 22 | 23 | for replyContent in soup.find_all(class_='plc cl'): 24 | if replyContent.find(class_='display pi'): 25 | reply = {} 26 | reply['avatar'] = replyContent.find(class_='avatar') 27 | reply['author']=replyContent.find(class_='blue').get_text() 28 | reply['message']=replyContent.find(class_='message') 29 | msgList.append(reply) 30 | print(reply) 31 | 32 | -------------------------------------------------------------------------------- /SgsClub/View/BottomButton.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtCore import QSize 2 | from PyQt5.QtWidgets import QToolButton 3 | from qtpy import QtCore 4 | from qtpy import QtGui 5 | 6 | class BottomButton(QToolButton): 7 | def __init__(self, parent = None): 8 | super().__init__(parent) 9 | self.setAutoExclusive(True) 10 | self.setCheckable(True) 11 | self.setIconSize(QSize(35, 35)) 12 | 13 | def enterEvent(self, QEvent): 14 | self.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) 15 | 16 | def leaveEvent(self, QEvent): 17 | self.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) -------------------------------------------------------------------------------- /SgsClub/View/BottomPart.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | from PyQt5 import QtWidgets 4 | from PyQt5.QtCore import * 5 | from PyQt5.QtGui import QIcon 6 | from PyQt5.QtWidgets import * 7 | 8 | from View.BottomButton import BottomButton 9 | 10 | 11 | class BottomPart(QWidget): 12 | homeSignal = pyqtSignal() 13 | meSignal = pyqtSignal() 14 | def __init__(self, parent = None): 15 | super().__init__(parent) 16 | 17 | #self.loadDataThread = LoadHomeDataThread() 18 | 19 | styleFile = QFile("../data/style/bottom.css") 20 | if styleFile.open(QIODevice.ReadOnly): 21 | stream = QTextStream(styleFile) 22 | self.setStyleSheet(stream.readAll()) 23 | 24 | bgWgt = QWidget() 25 | bgWgt.setObjectName('bottomWgt') 26 | hrLayout = QHBoxLayout(self) 27 | hrLayout.setContentsMargins(0, 0, 0, 0) 28 | hrLayout.addWidget(bgWgt) 29 | 30 | self.homeBtn = BottomButton() 31 | homeIcon = QIcon(r'..\data\images\bottom\home_n.png') 32 | homeIcon.addFile(r'..\data\images\bottom\home_s.png', QSize(40, 40), QIcon.Active, QIcon.On) 33 | self.homeBtn.setIcon(homeIcon) 34 | self.homeBtn.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) 35 | self.homeBtn.setText("首页") 36 | 37 | self.msgBtn = BottomButton() 38 | msgIcon = QIcon(r'..\data\images\bottom\msg_n.png') 39 | msgIcon.addFile(r'..\data\images\bottom\msg_s.png', QSize(40, 40), QIcon.Active, QIcon.On) 40 | self.msgBtn.setIcon(msgIcon) 41 | self.msgBtn.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) 42 | self.msgBtn.setText("消息") 43 | 44 | self.postBtn = QPushButton() 45 | self.postBtn.setFixedSize(50, 50) 46 | self.postBtn.setObjectName('postBtn') 47 | 48 | self.searchBtn = BottomButton() 49 | searchIcon = QIcon(r'..\data\images\bottom\search_n.png') 50 | searchIcon.addFile(r'..\data\images\bottom\search_s.png', QSize(40, 40), QIcon.Active, QIcon.On) 51 | self.searchBtn.setIcon(searchIcon) 52 | self.searchBtn.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) 53 | self.searchBtn.setText("搜索") 54 | 55 | self.meBtn = BottomButton() 56 | meIcon = QIcon(r'..\data\images\bottom\me_n.png') 57 | meIcon.addFile(r'..\data\images\bottom\me_s.png', QSize(40, 40), QIcon.Active, QIcon.On) 58 | self.meBtn.setIcon(meIcon) 59 | self.meBtn.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) 60 | self.meBtn.setText("我") 61 | 62 | hrLayout = QHBoxLayout(bgWgt) 63 | hrLayout.setContentsMargins(10, 0, 10, 0) 64 | hrLayout.addWidget(self.homeBtn) 65 | hrLayout.addStretch() 66 | hrLayout.addWidget(self.msgBtn) 67 | hrLayout.addStretch() 68 | hrLayout.addWidget(self.postBtn) 69 | hrLayout.addStretch() 70 | hrLayout.addWidget(self.searchBtn) 71 | hrLayout.addStretch() 72 | hrLayout.addWidget(self.meBtn) 73 | 74 | self.homeBtn.clicked.connect(self.homeBtnClicked) 75 | self.meBtn.clicked.connect(self.meBtnClicked) 76 | 77 | def homeBtnClicked(self): 78 | self.homeSignal.emit() 79 | 80 | def meBtnClicked(self): 81 | self.meSignal.emit() 82 | 83 | def setHomeSelected(self): 84 | self.homeBtn.animateClick() 85 | 86 | 87 | if __name__ == '__main__': 88 | app = QtWidgets.QApplication(sys.argv) 89 | mainWgt = BottomPart() 90 | mainWgt.show() 91 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /SgsClub/View/HomePostsWidget.py: -------------------------------------------------------------------------------- 1 | #首页帖子 2 | 3 | import sys 4 | import os 5 | from PyQt5 import QtWidgets, QtCore 6 | from PyQt5.QtCore import * 7 | from PyQt5.QtWebKit import QWebSettings 8 | from PyQt5.QtWidgets import * 9 | from PyQt5.QtWebKitWidgets import * 10 | 11 | class HomePostsWidget(QWidget): 12 | beginHtml = ''' 13 | 14 | 15 | 16 | 22 | 23 | 24 |
25 | ''' 26 | endHtml = ''' 27 |
28 | 29 | 30 | ''' 31 | postLinkSignal = pyqtSignal(str) 32 | def __init__(self, parent = None): 33 | super().__init__(parent) 34 | self.setStyleSheet("background:transparent;") 35 | bgWgt = QWidget() 36 | hrLayout = QHBoxLayout(self) 37 | hrLayout.setContentsMargins(0, 0, 0, 0) 38 | hrLayout.addWidget(bgWgt) 39 | 40 | self.webView = QWebView() 41 | self.webView.settings().setAttribute(QWebSettings.AutoLoadImages, True) 42 | self.webView.settings().setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, True) 43 | self.webView.settings().setAttribute(QWebSettings.LocalContentCanAccessFileUrls, True) 44 | self.webView.settings().setAttribute(QWebSettings.LocalStorageDatabaseEnabled, True) 45 | self.webView.settings().setUserStyleSheetUrl(QUrl.fromLocalFile(os.getcwd()+'/css/homeposts.css')) 46 | self.webView.loadFinished.connect(self.htmlLoadFinished) 47 | 48 | vrLayout = QVBoxLayout(bgWgt) 49 | vrLayout.setContentsMargins(0, 0, 0, 0) 50 | vrLayout.addWidget(self.webView) 51 | 52 | html = ''' 53 | 54 | 55 | 56 | 62 | 63 | 64 |
65 |
66 |
社区活动,三国杀拜师堂
67 |
68 |
69 | 70 |
严白虎的寄篱有个问题哎
71 |
post by 恋恋风尘
72 |
邓艾濒死,使用红色的酒自救。他与我的距离为1,我发动寄篱,那么问题来了 73 | 我既然成为了酒的目标,为什么我也恢复1体力,而不是令杀的伤害加一的效果?请详...
74 |
75 |
76 |
严白虎的寄篱有个问题哎
77 |
post by 恋恋风尘
78 |
邓艾濒死,使用红色的酒自救。他与我的距离为1,我发动寄篱,那么问题来了 79 | 我既然成为了酒的目标,为什么我也恢复1体力,而不是令杀的伤害加一的效果?请详...
80 |
81 |
82 |
严白虎的寄篱有个问题哎
83 |
post by 恋恋风尘
84 |
邓艾濒死,使用红色的酒自救。他与我的距离为1,我发动寄篱,那么问题来了 85 | 我既然成为了酒的目标,为什么我也恢复1体力,而不是令杀的伤害加一的效果?请详...
86 |
87 |
88 |
严白虎的寄篱有个问题哎
89 |
post by 恋恋风尘
90 |
邓艾濒死,使用红色的酒自救。他与我的距离为1,我发动寄篱,那么问题来了 91 | 我既然成为了酒的目标,为什么我也恢复1体力,而不是令杀的伤害加一的效果?请详...
92 |
93 |
94 |
严白虎的寄篱有个问题哎
95 |
post by 恋恋风尘
96 |
邓艾濒死,使用红色的酒自救。他与我的距离为1,我发动寄篱,那么问题来了 97 | 我既然成为了酒的目标,为什么我也恢复1体力,而不是令杀的伤害加一的效果?请详...
98 |
99 |
100 |
严白虎的寄篱有个问题哎
101 |
post by 恋恋风尘
102 |
邓艾濒死,使用红色的酒自救。他与我的距离为1,我发动寄篱,那么问题来了 103 | 我既然成为了酒的目标,为什么我也恢复1体力,而不是令杀的伤害加一的效果?请详...
104 |
105 |
106 | 107 | 108 | ''' 109 | self.webView.setHtml(html) 110 | 111 | def htmlLoadFinished(self, ready): 112 | if not ready: 113 | return 114 | self.webView.page().mainFrame().addToJavaScriptWindowObject("pyObj", self) 115 | 116 | #刷新数据(外部接口) 117 | def refreshContent(self, topList, downList): 118 | html = self.beginHtml 119 | for topPost in topList: 120 | newHtml = ''' 121 |
122 | 123 |
{2}
124 |
'''.format(topPost['link'], topPost['style'], topPost['title']) 125 | html += newHtml 126 | for downPost in downList: 127 | newHtml = ''' 128 |
129 | 130 |
{1}
131 |
post by {2}
132 |
{3}
133 |
134 | '''.format(downPost['link'], downPost['title'], downPost['author'], downPost['summary']) 135 | html += newHtml 136 | html += self.endHtml 137 | self.webView.setHtml(html) 138 | 139 | @QtCore.pyqtSlot(str) 140 | def getLinkSlot(self, link): 141 | self.postLinkSignal.emit(link) 142 | 143 | if __name__ == '__main__': 144 | app = QtWidgets.QApplication(sys.argv) 145 | mainWgt = HomePostsWidget() 146 | mainWgt.show() 147 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /SgsClub/View/HomeTop.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtCore import * 4 | from PyQt5.QtWidgets import * 5 | 6 | class HomeTop(QWidget): 7 | def __init__(self, parent = None): 8 | super().__init__(parent) 9 | 10 | bgWgt = QWidget() 11 | hrLayout = QHBoxLayout(self) 12 | hrLayout.setContentsMargins(0, 0, 0, 0) 13 | hrLayout.addWidget(bgWgt) 14 | bgWgt.setObjectName('hometopWgt') 15 | 16 | styleFile = QFile("../data/style/hometop.css") 17 | if styleFile.open(QIODevice.ReadOnly): 18 | stream = QTextStream(styleFile) 19 | self.setStyleSheet(stream.readAll()) 20 | 21 | self.friendBtn = QPushButton() 22 | self.friendBtn.setObjectName('friendBtn') 23 | self.friendBtn.setFixedSize(35, 35) 24 | self.titleBtn = QPushButton() 25 | self.titleBtn.setObjectName('titleBtn') 26 | self.titleBtn.setText('首页') 27 | self.tempBtn = QPushButton() 28 | self.tempBtn.setObjectName('tempBtn') 29 | self.tempBtn.setFixedSize(35, 35) 30 | 31 | hrLayout1 = QHBoxLayout(bgWgt) 32 | hrLayout1.setContentsMargins(10, 4, 10, 4) 33 | hrLayout1.addWidget(self.friendBtn) 34 | hrLayout1.addStretch() 35 | hrLayout1.addWidget(self.titleBtn) 36 | hrLayout1.addStretch() 37 | hrLayout1.addWidget(self.tempBtn) 38 | 39 | if __name__ == '__main__': 40 | app = QtWidgets.QApplication(sys.argv) 41 | mainWgt = HomeTop() 42 | mainWgt.show() 43 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /SgsClub/View/LoginWidget.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtCore import * 4 | from PyQt5.QtWidgets import * 5 | 6 | class LoginWidget(QWidget): 7 | loginSignal = pyqtSignal(str, str) 8 | def __init__(self, parent = None): 9 | super().__init__(parent) 10 | 11 | bgWgt = QWidget() 12 | hrLayout = QHBoxLayout(self) 13 | hrLayout.setContentsMargins(0, 0, 0, 0) 14 | hrLayout.addWidget(bgWgt) 15 | bgWgt.setObjectName('bgWgt') 16 | 17 | styleFile = QFile("../data/style/login.css") 18 | if styleFile.open(QIODevice.ReadOnly): 19 | stream = QTextStream(styleFile) 20 | self.setStyleSheet(stream.readAll()) 21 | 22 | hrLayout1 = QHBoxLayout() 23 | logoLbl = QLabel() 24 | logoLbl.setFixedSize(210, 130) 25 | logoLbl.setObjectName('logoLbl') 26 | hrLayout1.addStretch() 27 | hrLayout1.addWidget(logoLbl) 28 | hrLayout1.addStretch() 29 | 30 | self.userNameEdit = QLineEdit() 31 | self.pwdEdit = QLineEdit() 32 | self.loginBtn = QPushButton() 33 | self.userNameEdit.setObjectName('userNameEdit') 34 | self.pwdEdit.setObjectName('pwdEdit') 35 | self.loginBtn.setObjectName('loginBtn') 36 | self.loginBtn.setMinimumHeight(26) 37 | self.pwdEdit.setEchoMode(QLineEdit.Password) 38 | self.userNameEdit.setPlaceholderText('用户名') 39 | self.pwdEdit.setPlaceholderText('密码') 40 | self.loginBtn.setText('登录') 41 | vrLayout = QVBoxLayout(bgWgt) 42 | vrLayout.setSpacing(30) 43 | vrLayout.addStretch() 44 | vrLayout.addLayout(hrLayout1) 45 | vrLayout.addWidget(self.userNameEdit) 46 | vrLayout.addWidget(self.pwdEdit) 47 | vrLayout.addWidget(self.loginBtn) 48 | vrLayout.addStretch() 49 | 50 | self.loginBtn.clicked.connect(self.loginBtnClicked) 51 | 52 | #登录按钮单击 53 | def loginBtnClicked(self): 54 | self.loginSignal.emit(self.userNameEdit.text(), self.pwdEdit.text()) 55 | 56 | 57 | if __name__ == '__main__': 58 | app = QtWidgets.QApplication(sys.argv) 59 | mainWgt = LoginWidget() 60 | mainWgt.show() 61 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /SgsClub/View/PostTopWidget.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtCore import * 4 | from PyQt5.QtWidgets import * 5 | 6 | class PostTopWidget(QWidget): 7 | homeSignal = pyqtSignal() 8 | def __init__(self, parent = None): 9 | super().__init__(parent) 10 | 11 | bgWgt = QWidget() 12 | hrLayout = QHBoxLayout(self) 13 | hrLayout.setContentsMargins(0, 0, 0, 0) 14 | hrLayout.addWidget(bgWgt) 15 | bgWgt.setObjectName('posttopWgt') 16 | 17 | styleFile = QFile("../data/style/posttop.css") 18 | if styleFile.open(QIODevice.ReadOnly): 19 | stream = QTextStream(styleFile) 20 | self.setStyleSheet(stream.readAll()) 21 | 22 | self.returnHome = QPushButton() 23 | self.returnHome.setObjectName('returnHome') 24 | self.returnHome.setFixedSize(19, 35) 25 | self.titleBtn = QPushButton() 26 | self.titleBtn.setObjectName('titleBtn') 27 | self.titleBtn.setText('帖子正文') 28 | self.tempBtn = QPushButton() 29 | self.tempBtn.setObjectName('tempBtn') 30 | self.tempBtn.setFixedSize(35, 35) 31 | 32 | hrLayout1 = QHBoxLayout(bgWgt) 33 | hrLayout1.setContentsMargins(10, 4, 10, 4) 34 | hrLayout1.addWidget(self.returnHome) 35 | hrLayout1.addStretch() 36 | hrLayout1.addWidget(self.titleBtn) 37 | hrLayout1.addStretch() 38 | hrLayout1.addWidget(self.tempBtn) 39 | 40 | self.returnHome.clicked.connect(self.returnHomeBtnClicked) 41 | 42 | def returnHomeBtnClicked(self): 43 | self.homeSignal.emit() 44 | 45 | if __name__ == '__main__': 46 | app = QtWidgets.QApplication(sys.argv) 47 | mainWgt = PostTopWidget() 48 | mainWgt.show() 49 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /SgsClub/View/ReplyPostWidget.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | from PyQt5 import QtWidgets, QtCore 4 | from PyQt5.QtCore import * 5 | from PyQt5.QtWebKit import QWebSettings 6 | from PyQt5.QtWidgets import * 7 | from PyQt5.QtWebKitWidgets import * 8 | 9 | class ReplyPostWidget(QWidget): 10 | commentSignal = pyqtSignal(str) 11 | def __init__(self, parent = None): 12 | super().__init__(parent) 13 | bgWgt = QWidget() 14 | bgWgt.setObjectName('bgWgt') 15 | hrLayout = QHBoxLayout(self) 16 | hrLayout.setContentsMargins(0, 0, 0, 0) 17 | hrLayout.addWidget(bgWgt) 18 | 19 | styleFile = QFile("../data/style/reply.css") 20 | if styleFile.open(QIODevice.ReadOnly): 21 | stream = QTextStream(styleFile) 22 | self.setStyleSheet(stream.readAll()) 23 | 24 | self.commentEdit = QLineEdit() 25 | self.commentEdit.setObjectName('commentEdit') 26 | self.commentEdit.setMinimumHeight(26) 27 | self.commentEdit.setPlaceholderText('写回复...') 28 | self.commentBtn = QPushButton() 29 | self.commentBtn.setObjectName('commentBtn') 30 | self.commentBtn.setText('发 送') 31 | self.commentBtn.setFixedSize(46, 26) 32 | hrLayout1 = QHBoxLayout(bgWgt) 33 | hrLayout1.setContentsMargins(5, 5, 5, 5) 34 | hrLayout1.setSpacing(5) 35 | hrLayout1.addWidget(self.commentEdit) 36 | hrLayout1.addWidget(self.commentBtn) 37 | 38 | self.commentBtn.clicked.connect(self.onCommentBtnClicked) 39 | 40 | def onCommentBtnClicked(self): 41 | comment = self.commentEdit.text() 42 | self.commentSignal.emit(comment) 43 | 44 | if __name__ == '__main__': 45 | app = QtWidgets.QApplication(sys.argv) 46 | mainWgt = ReplyPostWidget() 47 | mainWgt.show() 48 | sys.exit(app.exec_()) 49 | -------------------------------------------------------------------------------- /SgsClub/View/ResizableWidget.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtCore import * 4 | from PyQt5.QtWidgets import * 5 | from qtpy import QtCore 6 | from qtpy import QtGui 7 | 8 | class ResizableWidget(QWidget): 9 | _resizable = True 10 | _marginWidth = 4 11 | _bPressed = False 12 | def __init__(self, parent = None): 13 | super().__init__(parent) 14 | #self.setAttribute(Qt.WA_TranslucentBackground) 15 | self.setWindowFlags(Qt.FramelessWindowHint | Qt.Window) 16 | self.setAttribute(Qt.WA_Hover) 17 | self.installEventFilter(self) 18 | 19 | def changeMouseStyle(self, point): 20 | if not self._resizable: 21 | self.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) 22 | self._mouseStyle = 0 23 | return 24 | 25 | iPosX = point.x() 26 | iPosY = point.y() 27 | 28 | iWidth = self.width() 29 | iHeight = self.height() 30 | if (iPosX >= iWidth - self._marginWidth and iPosX <= iWidth): 31 | self.setCursor(QtGui.QCursor(QtCore.Qt.SizeHorCursor))#右 32 | if (iPosY >= iHeight - self._marginWidth and iPosY <= iHeight): 33 | self.setCursor(QtGui.QCursor(QtCore.Qt.SizeFDiagCursor))#右下 34 | self._mouseStyle = 5 35 | return 36 | self._mouseStyle = 4 37 | return 38 | 39 | if (iPosY >= iHeight - self._marginWidth and iPosY <= iHeight): 40 | self.setCursor(QtGui.QCursor(QtCore.Qt.SizeVerCursor))#下 41 | self._mouseStyle = 6 42 | return 43 | 44 | self.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))#正常样式 45 | self._mouseStyle = 0; 46 | return 47 | 48 | def eventFilter(self, obj, event): 49 | #鼠标移动 50 | if event.type() == QtCore.QEvent.HoverMove: 51 | if not self._bPressed: 52 | self.changeMouseStyle(event.pos()) 53 | else: 54 | ptGlobalPos = self.mapToGlobal(event.pos()) 55 | ptTopLeft = self.frameGeometry().topLeft() 56 | ptBottomRight = self.frameGeometry().bottomRight() 57 | if self._mouseStyle == 0: 58 | self.move(self.mapToGlobal(event.pos()) - self._ptPressPos) 59 | return True 60 | elif self._mouseStyle == 4: 61 | if (ptGlobalPos.x() - ptTopLeft.x() > self.minimumWidth()): 62 | ptBottomRight.setX(ptGlobalPos.x()) 63 | else: 64 | ptBottomRight.setX(ptTopLeft.x() + self.minimumWidth()) 65 | elif self._mouseStyle == 6: 66 | if (ptGlobalPos.y() - ptTopLeft.y() > self.minimumHeight()): 67 | ptBottomRight.setY(ptGlobalPos.y()) 68 | else: 69 | ptBottomRight.setY(ptTopLeft.y() + self.minimumHeight()) 70 | elif self._mouseStyle == 5: 71 | if (ptGlobalPos.x() - ptTopLeft.x() > self.minimumWidth()): 72 | ptBottomRight.setX(ptGlobalPos.x()) 73 | else: 74 | ptBottomRight.setX(ptTopLeft.x() + self.minimumWidth()) 75 | if (ptGlobalPos.y() - ptTopLeft.y() > self.minimumHeight()): 76 | ptBottomRight.setY(ptGlobalPos.y()) 77 | else: 78 | ptBottomRight.setY(ptTopLeft.y() + self.minimumHeight()) 79 | self.setGeometry(QRect(ptTopLeft, ptBottomRight)) 80 | 81 | #鼠标按下 82 | elif event.type() == QtCore.QEvent.MouseButtonPress: 83 | pressPt = event.pos() 84 | if (pressPt.y() <= 50 or self._mouseStyle != 0): 85 | self._bPressed = True 86 | self._ptPressPos = event.globalPos() - self.frameGeometry().topLeft() 87 | 88 | #鼠标松开 89 | elif event.type() == QtCore.QEvent.MouseButtonRelease: 90 | self._bPressed = False 91 | 92 | elif event.type() == QtCore.QEvent.ScrollPrepare: 93 | if(self._mouseStyle != 0): 94 | print(22) 95 | return False; 96 | return False 97 | 98 | 99 | if __name__ == '__main__': 100 | app = QtWidgets.QApplication(sys.argv) 101 | mainWgt = ResizableWidget() 102 | mainWgt.show() 103 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /SgsClub/View/SgsClubMain.py: -------------------------------------------------------------------------------- 1 | #主界面 2 | 3 | import sys 4 | from PyQt5 import QtWidgets 5 | from PyQt5.QtCore import * 6 | from PyQt5.QtWidgets import * 7 | from View.ResizableWidget import ResizableWidget 8 | from View.BottomPart import BottomPart 9 | from View.HomeTop import HomeTop 10 | from View.HomePostsWidget import HomePostsWidget 11 | from View.SinglePostWidget import SinglePostWidget 12 | from View.LoginWidget import LoginWidget 13 | from Control.HomePageThread import HomePageThread 14 | from Control.PostPageThread import PostPageThread 15 | from Control.SgsClub import SgsClub 16 | 17 | class SgsClubMain(ResizableWidget): 18 | def __init__(self, parent=None): 19 | #初始化 20 | super().__init__(parent) 21 | hrLayout = QHBoxLayout(self) 22 | hrLayout.setContentsMargins(0, 0, 0, 0) 23 | bgWgt = QWidget() 24 | bgWgt.setObjectName('clubMain') 25 | hrLayout.addWidget(bgWgt) 26 | 27 | #是否已登录 28 | self.isLogin = False 29 | 30 | #加载样式表 31 | styleFile = QFile("../data/style/main.css") 32 | if styleFile.open(QIODevice.ReadOnly): 33 | stream = QTextStream(styleFile) 34 | self.setStyleSheet(stream.readAll()) 35 | 36 | #stackedWidget 37 | homeWgt = QWidget()#首页,第0页 38 | #self.postWgt = SinglePostWgt() 39 | 40 | 41 | #首页 42 | homeTop = HomeTop() 43 | self.postsWgt = HomePostsWidget()#首页帖子widget 44 | vrLayout1 = QVBoxLayout(homeWgt) 45 | vrLayout1.setContentsMargins(0, 0, 0, 0) 46 | vrLayout1.addWidget(homeTop) 47 | vrLayout1.addWidget(self.postsWgt) 48 | 49 | #单个帖子 50 | self.postWgt = SinglePostWidget() 51 | 52 | #登录 53 | self.loginWgt = LoginWidget() 54 | 55 | self.stackedWgt = QStackedWidget() 56 | self.stackedWgt.addWidget(homeWgt) 57 | self.stackedWgt.addWidget(self.postWgt) 58 | self.stackedWgt.addWidget(self.loginWgt) 59 | 60 | vrLayout = QVBoxLayout(bgWgt) 61 | vrLayout.setContentsMargins(0, 0, 0, 0) 62 | self.bottomPart = BottomPart() 63 | vrLayout.addWidget(self.stackedWgt) 64 | vrLayout.addWidget(self.bottomPart) 65 | 66 | self.resize(370, 600) 67 | 68 | #加载数据的线程 69 | self.loadHomePageThread = HomePageThread()#首页 70 | self.loadPostPageThread = PostPageThread()#帖子 71 | 72 | #信号槽连接 73 | self.bottomPart.homeSignal.connect(self.homeBtnClicked) 74 | self.loadHomePageThread.postDataSignal.connect(self.refreshHomePageSlot) 75 | self.postsWgt.postLinkSignal.connect(self.openPostSlot) 76 | self.loadPostPageThread.postDataSignal.connect(self.loadPostData) 77 | self.postWgt.homeSignal.connect(self.returnToHome) 78 | self.bottomPart.meSignal.connect(self.meBtnClicked) 79 | self.loginWgt.loginSignal.connect(self.loginClubSlot) 80 | self.postWgt.replySignal.connect(self.replyToPost) 81 | 82 | #登录、发帖、回帖 83 | self.sgsClub = SgsClub() 84 | 85 | 86 | #首页按钮单击,刷新首页内容 87 | def homeBtnClicked(self): 88 | if self.stackedWgt.currentIndex() != 0: 89 | self.stackedWgt.setCurrentIndex(0) 90 | return 91 | self.loadHomePageThread.terminate() 92 | self.loadHomePageThread.start() 93 | 94 | #刷新首页数据线程完成槽函数 95 | def refreshHomePageSlot(self, topList, downList): 96 | self.loadHomePageThread.terminate() 97 | self.postsWgt.refreshContent(topList, downList) 98 | #print(topList) 99 | #print(downList) 100 | 101 | #点击帖子,打开帖子,加载数据 102 | def openPostSlot(self, link): 103 | self.loadPostPageThread.terminate() 104 | self.loadPostPageThread.setPostLink(link) 105 | self.loadPostPageThread.start() 106 | 107 | 108 | #加载帖子线程完成槽函数 109 | def loadPostData(self, postid, postData): 110 | self.loadPostPageThread.terminate() 111 | self.stackedWgt.setCurrentIndex(1) 112 | self.bottomPart.hide() 113 | self.postWgt.setPostId(postid) 114 | self.postWgt.setPostContent(postData) 115 | 116 | #回到首页槽函数 117 | def returnToHome(self): 118 | self.stackedWgt.setCurrentIndex(0) 119 | self.bottomPart.show() 120 | print('回到首页了') 121 | 122 | def meBtnClicked(self): 123 | if not self.isLogin: 124 | self.stackedWgt.setCurrentIndex(2) 125 | 126 | def loginClubSlot(self, usrName, pwd): 127 | print(usrName) 128 | print(pwd) 129 | self.sgsClub.loginClub(usrName, pwd) 130 | self.sgsClub.setFormhash() 131 | self.isLogin = True 132 | #self.stackedWgt.setCurrentIndex(0) 133 | self.bottomPart.setHomeSelected() 134 | 135 | def replyToPost(self, postid, content): 136 | print(postid) 137 | print(content) 138 | self.sgsClub.reply(59, postid, content) 139 | 140 | if __name__ == '__main__': 141 | app = QtWidgets.QApplication(sys.argv) 142 | mainWgt = SgsClubMain() 143 | mainWgt.show() 144 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /SgsClub/View/SinglePostWidget.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | from PyQt5 import QtWidgets, QtCore 4 | from PyQt5.QtCore import * 5 | from PyQt5.QtWebKit import QWebSettings 6 | from PyQt5.QtWidgets import * 7 | from PyQt5.QtWebKitWidgets import * 8 | from View.ReplyPostWidget import ReplyPostWidget 9 | from View.PostTopWidget import PostTopWidget 10 | 11 | class SinglePostWidget(QWidget): 12 | beginHtml = ''' 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | ''' 21 | endHtml = ''' 22 |
23 | 24 | 25 | ''' 26 | homeSignal = pyqtSignal() 27 | replySignal = pyqtSignal(str, str) 28 | def __init__(self, parent = None): 29 | super().__init__(parent) 30 | bgWgt = QWidget() 31 | hrLayout = QHBoxLayout(self) 32 | hrLayout.setContentsMargins(0, 0, 0, 0) 33 | hrLayout.addWidget(bgWgt) 34 | 35 | self.posttopWgt = PostTopWidget() 36 | self.webView = QWebView() 37 | self.webView.settings().setDefaultTextEncoding("GB2312") 38 | self.webView.settings().setUserStyleSheetUrl(QUrl.fromLocalFile(os.getcwd()+'/css/post.css')) 39 | self.commentWgt = ReplyPostWidget() 40 | vrLayout = QVBoxLayout(bgWgt) 41 | vrLayout.setContentsMargins(0, 0, 0, 0) 42 | vrLayout.setSpacing(0) 43 | vrLayout.addWidget(self.posttopWgt) 44 | vrLayout.addWidget(self.webView) 45 | vrLayout.addWidget(self.commentWgt) 46 | 47 | self.posttopWgt.homeSignal.connect(self.homeBtnClicked) 48 | self.commentWgt.commentSignal.connect(self.replyBtnClicked) 49 | 50 | def setPostId(self, postid): 51 | self.postid = postid 52 | 53 | 54 | #刷新数据(外部接口) 55 | def setPostContent(self, msgList): 56 | html = self.beginHtml 57 | for postContent in msgList: 58 | #print(postContent) 59 | content = str(postContent['message']) 60 | content = content.replace('src="','src="http://club.sanguosha.com/') 61 | newHtml = '''
62 |
63 |
{1}
64 |
65 |
{2}
66 |
67 |
68 | '''.format(postContent['avatar'],postContent['author'],content) 69 | html += newHtml 70 | print('界面中帖子内容加载结束') 71 | html += self.endHtml 72 | #print(html) 73 | postfile = open(os.getcwd()+'/pages/post.html', 'w',encoding='utf-8') 74 | postfile.write(html) 75 | postfile.close() 76 | url = QUrl.fromLocalFile(os.getcwd()+'/pages/post.html') 77 | self.webView.load(url) 78 | 79 | #返回首页按钮单击 80 | def homeBtnClicked(self): 81 | print(1) 82 | self.homeSignal.emit() 83 | 84 | def replyBtnClicked(self, comment): 85 | self.replySignal.emit(self.postid, comment) 86 | 87 | 88 | if __name__ == '__main__': 89 | app = QtWidgets.QApplication(sys.argv) 90 | mainWgt = SinglePostWidget() 91 | mainWgt.show() 92 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /SgsClub/View/__pycache__/BottomButton.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/View/__pycache__/BottomButton.cpython-35.pyc -------------------------------------------------------------------------------- /SgsClub/View/__pycache__/BottomPart.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/View/__pycache__/BottomPart.cpython-35.pyc -------------------------------------------------------------------------------- /SgsClub/View/__pycache__/HomePostsWidget.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/View/__pycache__/HomePostsWidget.cpython-35.pyc -------------------------------------------------------------------------------- /SgsClub/View/__pycache__/HomeTop.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/View/__pycache__/HomeTop.cpython-35.pyc -------------------------------------------------------------------------------- /SgsClub/View/__pycache__/LoginWidget.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/View/__pycache__/LoginWidget.cpython-35.pyc -------------------------------------------------------------------------------- /SgsClub/View/__pycache__/PostTopWidget.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/View/__pycache__/PostTopWidget.cpython-35.pyc -------------------------------------------------------------------------------- /SgsClub/View/__pycache__/ReplyPostWidget.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/View/__pycache__/ReplyPostWidget.cpython-35.pyc -------------------------------------------------------------------------------- /SgsClub/View/__pycache__/ResizableWidget.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/View/__pycache__/ResizableWidget.cpython-35.pyc -------------------------------------------------------------------------------- /SgsClub/View/__pycache__/SinglePostWidget.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/View/__pycache__/SinglePostWidget.cpython-35.pyc -------------------------------------------------------------------------------- /SgsClub/View/cookie.json: -------------------------------------------------------------------------------- 1 | {"W6kP_2132_lastact": "1487927286%09member.php%09logging", "CAS_LOGIN_STATE": "1", "W6kP_2132_lastvisit": "1487923686", "W6kP_2132_checkfollow": "1", "W6kP_2132_auth": "38f8SLGWYjX1O%2FffyS9dZdytqBckAZe%2BamXPrd6p4C060Mw6%2BBcCXsrSCUacXUX1pWvopxLQGRBvbbTqtN%2BN7zbFqQA", "CASTGC": "ULSTGT-9031e07b033b46709cffda424ebe2962", "W6kP_2132_saltkey": "eCc5ZzQ1", "W6kP_2132_lastcheckfeed": "119544%7C1487927286", "W6kP_2132_ulastactivity": "1487927286%7C0"} -------------------------------------------------------------------------------- /SgsClub/View/css/homeposts.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | font-family: '微软雅黑'; 4 | font-size:14px; 5 | padding: 0; 6 | margin: 0; 7 | } 8 | #bg 9 | { 10 | background-color: #f2f2f2; 11 | } 12 | .title 13 | { 14 | color:#f46200; 15 | padding:6px 6px 2px 9px; 16 | cursor: pointer; 17 | } 18 | .author span 19 | { 20 | color:#507daf; 21 | cursor: pointer; 22 | } 23 | .author 24 | { 25 | padding:2px 6px 2px 9px; 26 | color:#939393; 27 | } 28 | .content 29 | { 30 | padding:2px 6px 6px 9px; 31 | color: #333333; 32 | cursor: pointer; 33 | overflow-x:hidden; 34 | } 35 | .post 36 | { 37 | margin-bottom: 10px; 38 | background-color: #ffffff; 39 | } 40 | .post:hover 41 | { 42 | background-color:#d5d4d4; 43 | } 44 | 45 | .top 46 | { 47 | padding: 6px; 48 | cursor: pointer; 49 | } 50 | 51 | ::-webkit-scrollbar 52 | { 53 | width: 8px; 54 | background:transparent; 55 | } 56 | 57 | ::-webkit-scrollbar-thumb 58 | { 59 | border-radius: 4px; 60 | background-color: #a6a6a6; 61 | } -------------------------------------------------------------------------------- /SgsClub/View/css/post.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | font-family: '宋体'; 4 | font-size:14px; 5 | padding: 0; 6 | margin: 0; 7 | } 8 | 9 | 10 | ::-webkit-scrollbar 11 | { 12 | width: 8px; 13 | background:transparent; 14 | } 15 | 16 | ::-webkit-scrollbar-thumb 17 | { 18 | border-radius: 4px; 19 | background-color: #a6a6a6; 20 | } 21 | 22 | .avatar 23 | { 24 | margin:14px; 25 | width:50px; 26 | height:50px; 27 | border-radius:50%; 28 | overflow:hidden; 29 | } 30 | .avatar img 31 | { 32 | width: 100%; 33 | height: 100%; 34 | object-fit: cover; 35 | } 36 | 37 | .right{ 38 | margin-left:74px; background:#fff; 39 | min-height:60px; 40 | border-bottom: 1px solid #e6e6e6; 41 | } 42 | 43 | .left { 44 | width:68px; float:left; background:#fff; 45 | } 46 | 47 | .author 48 | { 49 | padding-top: 14px; 50 | color: #507daf; 51 | } 52 | 53 | .reply 54 | { 55 | margin:0 auto; overflow:auto; _display:inline-block; 56 | } 57 | 58 | .message 59 | { 60 | padding-top: 4px; 61 | padding-bottom: 10px; 62 | padding-right:4px; 63 | } 64 | 65 | .message img 66 | { 67 | max-width:160px; max-height:160px; 68 | } 69 | 70 | .reply 71 | { 72 | overflow-x:hidden; 73 | } -------------------------------------------------------------------------------- /SgsClub/View/js/post.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/View/js/post.js -------------------------------------------------------------------------------- /SgsClub/View/pages/post.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
10 |
11 |
瞒住机器
12 |
13 |
14 | 15 | 16 | 每周特惠武将算是买的最实惠时机吗。
17 | 主要是一将成名和SP武将
18 | 已经开通感觉比较强的
19 | 曹植
20 | 关兴张苞
21 | Sp赵云
22 | Sp蔡文姬
23 | Sp袁术
24 | 界黄盖
25 | 陈宫
26 | 沮授
27 |
28 |
29 | 还未开通打算买的
30 |
31 | 曹冲
32 | 曹叡
33 | 满宠
34 | 张星彩
35 | 钟繇
36 | 步练师
37 | 李儒
38 | 曹昂
39 | 诸葛瑾
40 | 王基
41 | 伏皇后
42 | 蔡夫人
43 | 李严
44 | 关银屏
45 | 何太后
46 | 文聘
47 |
48 |
49 | 大家还推荐界将
50 |
51 |
52 |
53 |
54 |
L、夜灵
55 |
56 |
57 | 58 | 59 | 刘协我认为是必开武将
60 |
61 |
62 |
63 |
64 |
京城名医曹大夫
65 |
66 |
67 | 68 | 69 | 王基
70 | 曹叡
71 | 张星彩
72 | 钟繇
73 | 步练师
74 | 李儒
75 | 曹昂
76 | 诸葛瑾
77 | 蔡夫人
78 | 何太后
79 |
80 |
81 |
82 |
83 |
京城名医曹大夫
84 |
85 |
86 | 87 | 88 | 王基、钟繇、曹睿首选强将
89 | 界马超、李典、刘备必备强将
90 | 界陆逊、司马、周瑜、大乔可视情况选配,界周瑜是打BOSS强将
91 |
92 |
93 |
94 |
95 |
影乱千江
96 |
97 |
98 | 99 | 100 | 界限,先吴国的,然后蜀国赵云也可以要增加sp赵云出场率,魏国先不要开,直接等开够了数去第二页开李典
101 |
102 |
103 |
104 |
105 |
仔白
106 |
107 |
108 | 109 | 110 | 王基
111 | 曹叡
112 |
113 |
114 |
115 |
116 |
arsenal
117 |
118 |
119 | 120 | 121 | 蔡夫人
122 |
123 |
124 |
125 |
126 |
花火o
127 |
128 |
129 | 130 | 131 | 曹冲√
132 | 曹叡√√
133 | 满宠√
134 | 张星彩√√
135 | 钟繇√√√
136 | 步练师√√√
137 | 李儒√√
138 | 曹昂√√
139 | 诸葛瑾√√
140 | 王基√√√
141 | 伏皇后(打44√√)不打X
142 | 蔡夫人√√
143 | 李严X
144 | 关银屏XXX
145 | 何太后√(打国战√√)(打44√√√)
146 | 文聘X(打44√√)
147 |
148 |
149 |
150 |
151 |
沐柳
152 |
153 |
154 | 155 | 156 | 。。。。关张没必要入手
157 |
158 |
159 |
160 |
161 |
老万
162 |
163 |
164 | 165 | 166 | 只买一个的话,推荐张让
167 |
168 |
169 | 170 |
171 | 172 | 173 | -------------------------------------------------------------------------------- /SgsClub/View/ttt.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | ccc = ''' 4 | 5 | 6 | 7 | 8 | 9 |
10 |
11 |
12 |
清剑鞘
13 |
14 |
15 | 16 | 17 | 我以前一直用一个浏览器加一个客户端来回切换有点麻烦,看到社区的一个多开的技术贴,就换用了他推荐的糖果浏览器,感觉界面和占用内存的情况都还好,可以会有掉线情况发生。好几次了,打排位掉线视为逃跑一次扣50要吐血了,有没有大神给支个招万分感谢
18 |
19 |
20 |
21 |
22 |
奶酪上的小喵团
23 |
24 |
25 | 26 | 27 | 360游戏大厅带你飞……
28 |
29 |
30 |
31 |
32 |
张昭
33 |
34 |
35 | 36 | 37 | 换个浏览器吧
38 |
39 |
40 |
41 |
42 |
尉迟如含
43 |
44 |
45 | 46 | 47 | 360游戏大厅,可多开!
48 |
49 |
50 |
51 |
52 |
轩辕焯护
53 |
54 |
55 | 我一般都是用360,说糖果的肯定是在推软广。
56 |
57 |
58 |
59 |
60 |
61 |
弓宁煌
62 |
63 |
64 | 65 | 66 | 双排还是找个好友开语音吧,多开其实就是每天刷刷任务罢了,打排位还是尽量不要多开,万一掉线就都掉了
67 |
68 |
69 |
70 |
71 |
7爷思密达
72 |
73 |
74 |
75 | 360游戏大厅带你飞……
76 |
77 |
78 |
79 |
80 |
羽毛
81 |
82 |
83 | 84 | 85 | 用XX大厅  或者XX盒子  多开无压力啊  用360游戏大厅  甚至可以做到小号直接点一下  直接登录  不需要输入ID 和MM的
86 |
87 |
88 | 89 |
90 | 91 | 92 | ''' 93 | 94 | postfile = open(os.getcwd()+'/pages/post.html', 'w',encoding='utf-8') 95 | postfile.write(ccc) 96 | print(111) -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/bulletscreen_icon_zoomin_excessive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/bulletscreen_icon_zoomin_excessive.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/card_icon_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/card_icon_arrow.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/compose_more_app_add_highlighted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/compose_more_app_add_highlighted.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/home_1s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/home_1s.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/home_3n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/home_3n.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/home_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/home_n.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/home_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/home_s.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/icon_1_new_d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/icon_1_new_d.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/icon_1_new_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/icon_1_new_n.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/icon_2_new_d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/icon_2_new_d.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/icon_2_new_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/icon_2_new_n.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/icon_3_new_d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/icon_3_new_d.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/icon_3_new_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/icon_3_new_n.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/market_icon_search_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/market_icon_search_normal.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/me_1n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/me_1n.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/me_1s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/me_1s.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/me_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/me_n.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/me_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/me_s.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/msg_1n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/msg_1n.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/msg_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/msg_n.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/msg_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/msg_s.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/msg_s1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/msg_s1.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/navigationbar_friendattention.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/navigationbar_friendattention.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/navigationbar_friendattention_dot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/navigationbar_friendattention_dot.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/navigationbar_friendattention_dot_highlighted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/navigationbar_friendattention_dot_highlighted.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/navigationbar_friendattention_highlighted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/navigationbar_friendattention_highlighted.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/navigationbar_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/navigationbar_home.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/navigationbar_home_highlighted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/navigationbar_home_highlighted.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/navigationbar_icon_health_mine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/navigationbar_icon_health_mine.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/navigationbar_icon_health_mine_highlighted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/navigationbar_icon_health_mine_highlighted.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/navigationbar_icon_health_mine_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/navigationbar_icon_health_mine_white.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/navigationbar_icon_health_mine_white_highlighted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/navigationbar_icon_health_mine_white_highlighted.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/post_1n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/post_1n.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/post_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/post_n.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/search_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/search_n.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/search_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/search_s.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_compose_icon_add@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_compose_icon_add@3x.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_discover@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_discover@3x.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_discover_highlighted@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_discover_highlighted@2x.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_discover_highlighted@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_discover_highlighted@3x.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_discover_selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_discover_selected@3x.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_home@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_home@3x.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_home_highlighted@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_home_highlighted@3x.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_home_selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_home_selected@2x.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_home_selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_home_selected@3x.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_message_center@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_message_center@3x.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_message_center_highlighted@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_message_center_highlighted@3x.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_message_center_selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_message_center_selected@2x.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_message_center_selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_message_center_selected@3x.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_profile@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_profile@3x.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_profile_highlighted@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_profile_highlighted@3x.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_profile_selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_profile_selected@2x.png -------------------------------------------------------------------------------- /SgsClub/data/images/bottom/tabbar_profile_selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/bottom/tabbar_profile_selected@3x.png -------------------------------------------------------------------------------- /SgsClub/data/images/hometop/friend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/hometop/friend.png -------------------------------------------------------------------------------- /SgsClub/data/images/hometop/hh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/hometop/hh.png -------------------------------------------------------------------------------- /SgsClub/data/images/hometop/hi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/hometop/hi.png -------------------------------------------------------------------------------- /SgsClub/data/images/login/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/login/logo.png -------------------------------------------------------------------------------- /SgsClub/data/images/posttop/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/posttop/home.png -------------------------------------------------------------------------------- /SgsClub/data/images/posttop/temp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/images/posttop/temp.png -------------------------------------------------------------------------------- /SgsClub/data/style/bottom.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/style/bottom.css -------------------------------------------------------------------------------- /SgsClub/data/style/hometop.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/style/hometop.css -------------------------------------------------------------------------------- /SgsClub/data/style/login.css: -------------------------------------------------------------------------------- 1 | QWidget 2 | { 3 | font-family:微软雅黑; 4 | font-size:16px; 5 | } 6 | 7 | #bgWgt 8 | { 9 | background-color: #ffffff; 10 | } 11 | 12 | #logoLbl 13 | { 14 | border-image:url(../data/images/login/logo.png); 15 | } 16 | 17 | #userNameEdit, #pwdEdit 18 | { 19 | background: transparent; 20 | border:none; 21 | border-bottom: 1px solid #dddddd; 22 | padding: 4px; 23 | } 24 | 25 | #loginBtn 26 | { 27 | background-color: #ff8505; 28 | color:#ffffff; 29 | border:none; 30 | border-radius:4px; 31 | } 32 | 33 | #loginBtn:hover 34 | { 35 | background-color: #fd9221; 36 | } 37 | 38 | #loginBtn:pressed 39 | { 40 | background-color: #eb7800; 41 | } -------------------------------------------------------------------------------- /SgsClub/data/style/main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/SgsClub/data/style/main.css -------------------------------------------------------------------------------- /SgsClub/data/style/post.css: -------------------------------------------------------------------------------- 1 | #singlePost 2 | { 3 | background:#ffffff; 4 | border-radius:4px; 5 | } 6 | 7 | #singlePost:hover 8 | { 9 | background: #d5d4d4; 10 | } 11 | 12 | #titleBtn 13 | { 14 | text-align:left; 15 | font-size:15px; 16 | padding-left:10px; 17 | color:#f46200 18 | } 19 | 20 | #nameBtn 21 | { 22 | text-align:left; 23 | font-size:14px; 24 | padding-left:10px; 25 | color:#939393 26 | } 27 | 28 | #summaryText 29 | { 30 | background: transparent; 31 | padding-left:6px; 32 | } -------------------------------------------------------------------------------- /SgsClub/data/style/posttop.css: -------------------------------------------------------------------------------- 1 | QWidget 2 | { 3 | color:#333333; 4 | font-family:微软雅黑; 5 | font-size:16px; 6 | } 7 | #hometopWgt 8 | { 9 | background-color:#f5f5f5; 10 | } 11 | #returnHome 12 | { 13 | border-image:url(../data/images/posttop/home.png); 14 | } 15 | #titleBtn 16 | { 17 | border:none; 18 | } 19 | #tempBtn 20 | { 21 | border-image:url(../data/images/posttop/temp.png); 22 | } -------------------------------------------------------------------------------- /SgsClub/data/style/reply.css: -------------------------------------------------------------------------------- 1 | QWidget 2 | { 3 | font-family:微软雅黑; 4 | font-size:14px; 5 | outline:0px; 6 | border:0px; 7 | } 8 | 9 | QPushButton 10 | { 11 | color:#ffffff; 12 | background:#1f91cf; 13 | border-radius:3px; 14 | padding-top:-2px; 15 | } 16 | QPushButton:hover 17 | { 18 | background:#1e99dd; 19 | } 20 | QPushButton:pressed 21 | { 22 | background:#1a77aa; 23 | } 24 | /* 02-按钮 end */ 25 | 26 | /* 03-QLineEdit begin */ 27 | QLineEdit, QTextEdit 28 | { 29 | background:#ffffff; 30 | border:1px solid #dadada; 31 | padding-left:5px; 32 | border-radius: 4px; 33 | } 34 | QLineEdit:disabled 35 | { 36 | color:grey; 37 | } -------------------------------------------------------------------------------- /StyleSheetDemo/StyleSheetDemo.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2017-01-29T20:27:51 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = StyleSheetDemo 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which as been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | 26 | SOURCES += main.cpp\ 27 | StyleTest.cpp 28 | 29 | HEADERS += StyleTest.h 30 | 31 | FORMS += StyleTest.ui 32 | 33 | RESOURCES += \ 34 | images.qrc 35 | -------------------------------------------------------------------------------- /StyleSheetDemo/StyleTest.cpp: -------------------------------------------------------------------------------- 1 | #include "StyleTest.h" 2 | #include "ui_StyleTest.h" 3 | 4 | StyleTest::StyleTest(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::StyleTest) 7 | { 8 | ui->setupUi(this); 9 | } 10 | 11 | StyleTest::~StyleTest() 12 | { 13 | delete ui; 14 | } 15 | -------------------------------------------------------------------------------- /StyleSheetDemo/StyleTest.h: -------------------------------------------------------------------------------- 1 | #ifndef STYLETEST_H 2 | #define STYLETEST_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class StyleTest; 8 | } 9 | 10 | class StyleTest : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit StyleTest(QWidget *parent = 0); 16 | ~StyleTest(); 17 | 18 | private: 19 | Ui::StyleTest *ui; 20 | }; 21 | 22 | #endif // STYLETEST_H 23 | -------------------------------------------------------------------------------- /StyleSheetDemo/images.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/button/button-h.png 4 | images/button/button-n.png 5 | images/button/button-s.png 6 | images/checkbox/check.png 7 | images/checkbox/uncheck.png 8 | images/slider/ply_btn_hvr.png 9 | images/slider/ply_btn.png 10 | images/radiobutton/checked.png 11 | images/radiobutton/checked_disabled.png 12 | images/radiobutton/checked_focus.png 13 | images/radiobutton/unchecked.png 14 | images/radiobutton/unchecked_disabled.png 15 | images/radiobutton/unchecked_focus.png 16 | images/tree/collapse.png 17 | images/tree/expand.png 18 | images/progressbar/prog.png 19 | images/progressbar/prog1.png 20 | images/progressbar/prog2.png 21 | images/progressbar/prog3.png 22 | 23 | 24 | -------------------------------------------------------------------------------- /StyleSheetDemo/images/button/button-h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/button/button-h.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/button/button-n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/button/button-n.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/button/button-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/button/button-s.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/checkbox/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/checkbox/check.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/checkbox/uncheck.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/checkbox/uncheck.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/progressbar/prog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/progressbar/prog.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/progressbar/prog1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/progressbar/prog1.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/progressbar/prog2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/progressbar/prog2.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/progressbar/prog3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/progressbar/prog3.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/radiobutton/checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/radiobutton/checked.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/radiobutton/checked_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/radiobutton/checked_disabled.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/radiobutton/checked_focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/radiobutton/checked_focus.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/radiobutton/unchecked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/radiobutton/unchecked.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/radiobutton/unchecked_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/radiobutton/unchecked_disabled.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/radiobutton/unchecked_focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/radiobutton/unchecked_focus.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/slider/ply_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/slider/ply_btn.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/slider/ply_btn_hvr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/slider/ply_btn_hvr.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/tree/collapse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/tree/collapse.png -------------------------------------------------------------------------------- /StyleSheetDemo/images/tree/expand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/StyleSheetDemo/images/tree/expand.png -------------------------------------------------------------------------------- /StyleSheetDemo/main.cpp: -------------------------------------------------------------------------------- 1 | #include "StyleTest.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | StyleTest w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /StyleSheetDemo/readme.md: -------------------------------------------------------------------------------- 1 | ##Qt控件样式 -------------------------------------------------------------------------------- /TreeSearch/README.md: -------------------------------------------------------------------------------- 1 | # Qt_TreeSearch 2 | 3 | ## 树的搜索 4 | 在项目中有时会对生成的树(QTreeWidget/QTreeView)结点进行搜索
5 | 本程序可以根据汉字、拼音全拼、首字母进行结点搜索
6 | 如果某结点匹配关键字,则显示其所有父节点及子节点
7 | 存在的问题:有些字拼音搜索搜不到、不支持多音字 8 | 9 | ### 1.普通版 10 | 使用方法:
11 | 调用函数TreeSearch::SearchItem(para1, para2);
12 | 第一个参数是要搜索的树QTreeWidget或它的子类
13 | 第二个参数是搜索输入的关键字
14 | 15 | ### 2.model-view版 16 | 使用方法:
17 | 调用函数TreeSearch::SearchItem(para1, para2, para3);
18 | 第一个参数是要搜索的树QTreeView或它的子类
19 | 第二个参数是树的数据模型QStandardItemModel或它的子类
20 | 第三个参数是搜索输入的关键字
21 | 22 | ## 截图 23 | ![](https://github.com/ikongziming/QtDemo/blob/master/TreeSearch/demo.png?raw=true) 24 | -------------------------------------------------------------------------------- /TreeSearch/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/TreeSearch/demo.png -------------------------------------------------------------------------------- /TreeSearch/model-view/TreeSearch.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/TreeSearch/model-view/TreeSearch.cpp -------------------------------------------------------------------------------- /TreeSearch/model-view/TreeSearch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/TreeSearch/model-view/TreeSearch.h -------------------------------------------------------------------------------- /TreeSearch/normal/TreeSearch.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/TreeSearch/normal/TreeSearch.cpp -------------------------------------------------------------------------------- /TreeSearch/normal/TreeSearch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongziming/QtDemo/bd68be4270d360feb2be934aa8563013f126762b/TreeSearch/normal/TreeSearch.h -------------------------------------------------------------------------------- /WebSocket/WebSocketTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "WebSocketTest.h" 5 | 6 | WebSocketTest::WebSocketTest(QWidget *parent) 7 | : QWidget(parent) 8 | { 9 | ui.setupUi(this); 10 | 11 | QPushButton *pBtn = new QPushButton(this); 12 | connect(pBtn, &QPushButton::clicked, [=] { 13 | m_pWebSocket->sendTextMessage("Msg from server"); 14 | }); 15 | 16 | m_pWebSocketServer = new QWebSocketServer("server", QWebSocketServer::NonSecureMode); 17 | m_pWebSocketServer->listen(QHostAddress::Any, 9999); 18 | connect(m_pWebSocketServer, SIGNAL(newConnection()), this, SLOT(acceptConnectionSlot())); 19 | } 20 | 21 | void WebSocketTest::acceptConnectionSlot() 22 | { 23 | m_pWebSocket = m_pWebSocketServer->nextPendingConnection(); 24 | 25 | connect(m_pWebSocket, SIGNAL(textMessageReceived(const QString &)), this, SLOT(textMsgRecivedSlot(const QString &))); 26 | connect(m_pWebSocket, SIGNAL(disconnected()), this, SLOT(socketDisconnectedSlot())); 27 | } 28 | 29 | void WebSocketTest::textMsgRecivedSlot(const QString &strMsg) 30 | { 31 | qDebug() << strMsg; 32 | } 33 | 34 | void WebSocketTest::socketDisconnectedSlot() 35 | { 36 | qDebug() << "Disconnected"; 37 | } 38 | -------------------------------------------------------------------------------- /WebSocket/WebSocketTest.h: -------------------------------------------------------------------------------- 1 | #ifndef WEBSOCKET_TEST_H 2 | #define WEBSOCKET_TEST_H 3 | 4 | #include 5 | #include "ui_WebSocketTest.h" 6 | 7 | #include 8 | #include 9 | 10 | class WebSocketTest : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | WebSocketTest(QWidget *parent = nullptr); 16 | 17 | private slots: 18 | void acceptConnectionSlot(); 19 | 20 | void textMsgRecivedSlot(const QString &); 21 | 22 | void socketDisconnectedSlot(); 23 | 24 | private: 25 | Ui::WebSocketTestClass ui; 26 | QWebSocketServer *m_pWebSocketServer; 27 | QWebSocket *m_pWebSocket; 28 | }; 29 | 30 | #endif // !WEBSOCKET_TEST_H 31 | -------------------------------------------------------------------------------- /WebSocket/WebSocketTest.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /WebSocket/WebSocketTest.ui: -------------------------------------------------------------------------------- 1 | 2 | WebSocketTestClass 3 | 4 | 5 | WebSocketTestClass 6 | 7 | 8 | 9 | 0 10 | 0 11 | 600 12 | 400 13 | 14 | 15 | 16 | WebSocketTest 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /WebSocket/client.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /WebSocket/main.cpp: -------------------------------------------------------------------------------- 1 | #include "WebSocketTest.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | WebSocketTest w; 8 | w.show(); 9 | return a.exec(); 10 | } 11 | --------------------------------------------------------------------------------