├── README.md ├── senddialog.h ├── sendtask.cpp ├── sendtask.h ├── senddialog.cpp ├── main.cpp ├── widget.h ├── pthread.pro ├── senddialog.ui ├── widget.cpp ├── widget.ui ├── pthread.pro.user.188a464 └── pthread.pro.user /README.md: -------------------------------------------------------------------------------- 1 | # QtThread 2 | Qt多线程实现进度条示例 3 | -------------------------------------------------------------------------------- /senddialog.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaoxd298/QtThread/HEAD/senddialog.h -------------------------------------------------------------------------------- /sendtask.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaoxd298/QtThread/HEAD/sendtask.cpp -------------------------------------------------------------------------------- /sendtask.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaoxd298/QtThread/HEAD/sendtask.h -------------------------------------------------------------------------------- /senddialog.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaoxd298/QtThread/HEAD/senddialog.cpp -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "widget.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "ui_widget.h" 6 | 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget, public Ui::Widget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = 0); 17 | ~Widget(); 18 | 19 | private slots: 20 | void click_scanButton(); 21 | void click_sendButton(); 22 | }; 23 | 24 | #endif // WIDGET_H 25 | -------------------------------------------------------------------------------- /pthread.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2016-05-05T10:55:00 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | QT += widgets 9 | 10 | TARGET = pthread 11 | TEMPLATE = app 12 | 13 | 14 | SOURCES += main.cpp\ 15 | widget.cpp \ 16 | senddialog.cpp \ 17 | sendtask.cpp 18 | 19 | HEADERS += widget.h \ 20 | senddialog.h \ 21 | sendtask.h 22 | 23 | FORMS += widget.ui \ 24 | senddialog.ui 25 | -------------------------------------------------------------------------------- /senddialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | sendDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 407 10 | 98 11 | 12 | 13 | 14 | Sending... 15 | 16 | 17 | 18 | 19 | 20 | 0 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | #include "senddialog.h" 4 | 5 | Widget::Widget(QWidget *parent) : 6 | QWidget(parent) 7 | { 8 | setupUi(this); 9 | 10 | path_name->setReadOnly(true); 11 | connect(scanButton, SIGNAL(clicked()), this, SLOT(click_scanButton())); 12 | connect(sendButton, SIGNAL(clicked()), this, SLOT(click_sendButton())); 13 | 14 | } 15 | 16 | Widget::~Widget() 17 | { 18 | } 19 | 20 | void Widget::click_scanButton() 21 | { 22 | QString file_path = QFileDialog::getOpenFileName(this, "please choose file"); 23 | if (file_path.length() > 0) { 24 | path_name->setText(file_path); 25 | } 26 | } 27 | 28 | void Widget::click_sendButton() 29 | { 30 | QString file_path = path_name->text(); 31 | if (file_path.length() > 0) { 32 | sendDialog send_dialog(file_path, this); 33 | send_dialog.exec(); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 369 10 | 108 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 浏览 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | Qt::Horizontal 37 | 38 | 39 | 40 | 40 41 | 20 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | Aharoni 51 | 12 52 | 75 53 | true 54 | 55 | 56 | 57 | 开始传送 58 | 59 | 60 | 61 | 62 | 63 | 64 | Qt::Horizontal 65 | 66 | 67 | 68 | 40 69 | 20 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /pthread.pro.user.188a464: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EnvironmentId 7 | {188a4649-b68d-4068-95ae-c1081530f238} 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 | System 33 | false 34 | 4 35 | false 36 | 80 37 | true 38 | true 39 | 1 40 | true 41 | false 42 | 1 43 | true 44 | 0 45 | 8 46 | true 47 | 1 48 | true 49 | true 50 | true 51 | false 52 | 53 | 54 | 55 | ProjectExplorer.Project.PluginSettings 56 | 57 | 58 | 59 | ProjectExplorer.Project.Target.0 60 | 61 | Desktop Qt 5.6.0 MinGW 32bit 62 | Desktop Qt 5.6.0 MinGW 32bit 63 | qt.56.win32_mingw49_kit 64 | 0 65 | 0 66 | 0 67 | 68 | C:/Users/sunshine/Desktop/qt/build-pthread-Desktop_Qt_5_6_0_MinGW_32bit-Debug 69 | 70 | 71 | true 72 | qmake 73 | 74 | QtProjectManager.QMakeBuildStep 75 | true 76 | 77 | false 78 | false 79 | false 80 | 81 | 82 | true 83 | Make 84 | 85 | Qt4ProjectManager.MakeStep 86 | 87 | false 88 | 89 | 90 | 91 | 2 92 | 构建 93 | 94 | ProjectExplorer.BuildSteps.Build 95 | 96 | 97 | 98 | true 99 | Make 100 | 101 | Qt4ProjectManager.MakeStep 102 | 103 | true 104 | clean 105 | 106 | 107 | 1 108 | 清理 109 | 110 | ProjectExplorer.BuildSteps.Clean 111 | 112 | 2 113 | false 114 | 115 | Debug 116 | 117 | Qt4ProjectManager.Qt4BuildConfiguration 118 | 2 119 | true 120 | 121 | 122 | C:/Users/sunshine/Desktop/qt/build-pthread-Desktop_Qt_5_6_0_MinGW_32bit-Release 123 | 124 | 125 | true 126 | qmake 127 | 128 | QtProjectManager.QMakeBuildStep 129 | false 130 | 131 | false 132 | false 133 | false 134 | 135 | 136 | true 137 | Make 138 | 139 | Qt4ProjectManager.MakeStep 140 | 141 | false 142 | 143 | 144 | 145 | 2 146 | 构建 147 | 148 | ProjectExplorer.BuildSteps.Build 149 | 150 | 151 | 152 | true 153 | Make 154 | 155 | Qt4ProjectManager.MakeStep 156 | 157 | true 158 | clean 159 | 160 | 161 | 1 162 | 清理 163 | 164 | ProjectExplorer.BuildSteps.Clean 165 | 166 | 2 167 | false 168 | 169 | Release 170 | 171 | Qt4ProjectManager.Qt4BuildConfiguration 172 | 0 173 | true 174 | 175 | 176 | C:/Users/sunshine/Desktop/qt/build-pthread-Desktop_Qt_5_6_0_MinGW_32bit-Profile 177 | 178 | 179 | true 180 | qmake 181 | 182 | QtProjectManager.QMakeBuildStep 183 | true 184 | 185 | false 186 | true 187 | false 188 | 189 | 190 | true 191 | Make 192 | 193 | Qt4ProjectManager.MakeStep 194 | 195 | false 196 | 197 | 198 | 199 | 2 200 | 构建 201 | 202 | ProjectExplorer.BuildSteps.Build 203 | 204 | 205 | 206 | true 207 | Make 208 | 209 | Qt4ProjectManager.MakeStep 210 | 211 | true 212 | clean 213 | 214 | 215 | 1 216 | 清理 217 | 218 | ProjectExplorer.BuildSteps.Clean 219 | 220 | 2 221 | false 222 | 223 | Profile 224 | 225 | Qt4ProjectManager.Qt4BuildConfiguration 226 | 0 227 | true 228 | 229 | 3 230 | 231 | 232 | 0 233 | 部署 234 | 235 | ProjectExplorer.BuildSteps.Deploy 236 | 237 | 1 238 | 在本地部署 239 | 240 | ProjectExplorer.DefaultDeployConfiguration 241 | 242 | 1 243 | 244 | 245 | false 246 | 1000 247 | 248 | true 249 | 250 | false 251 | false 252 | false 253 | false 254 | true 255 | 0.01 256 | 10 257 | true 258 | 1 259 | 25 260 | 261 | 1 262 | true 263 | false 264 | true 265 | valgrind 266 | 267 | 0 268 | 1 269 | 2 270 | 3 271 | 4 272 | 5 273 | 6 274 | 7 275 | 8 276 | 9 277 | 10 278 | 11 279 | 12 280 | 13 281 | 14 282 | 283 | 2 284 | 285 | pthread 286 | 287 | Qt4ProjectManager.Qt4RunConfiguration:C:/Users/sunshine/Desktop/qt/pthread/pthread.pro 288 | true 289 | 290 | pthread.pro 291 | false 292 | false 293 | 294 | 3768 295 | false 296 | true 297 | false 298 | false 299 | true 300 | 301 | 1 302 | 303 | 304 | 305 | ProjectExplorer.Project.TargetCount 306 | 1 307 | 308 | 309 | ProjectExplorer.Project.Updater.FileVersion 310 | 18 311 | 312 | 313 | Version 314 | 18 315 | 316 | 317 | -------------------------------------------------------------------------------- /pthread.pro.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EnvironmentId 7 | {424e5529-7423-4dd1-a67f-be7c0f2236d0} 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 | System 33 | false 34 | 4 35 | false 36 | 80 37 | true 38 | true 39 | 1 40 | true 41 | false 42 | 1 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.6.2 MinGW 32bit 63 | Desktop Qt 5.6.2 MinGW 32bit 64 | qt.56.win32_mingw49_kit 65 | 0 66 | 0 67 | 0 68 | 69 | C:/Users/sunshine/Desktop/qt/build-pthread-Desktop_Qt_5_6_0_MinGW_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/sunshine/Desktop/qt/build-pthread-Desktop_Qt_5_6_0_MinGW_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/sunshine/Desktop/qt/build-pthread-Desktop_Qt_5_6_0_MinGW_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 | pthread 288 | pthread2 289 | Qt4ProjectManager.Qt4RunConfiguration:E:/qt/pthread/pthread.pro 290 | true 291 | 292 | pthread.pro 293 | false 294 | 295 | C:/Users/sunshine/Desktop/qt/build-pthread-Desktop_Qt_5_6_0_MinGW_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 | --------------------------------------------------------------------------------