{"id":110105,"date":"2026-09-25T23:09:21","date_gmt":"2026-09-25T15:09:21","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/110105.html"},"modified":"2026-09-25T23:09:21","modified_gmt":"2026-09-25T15:09:21","slug":"%e3%80%8aqt%e4%bb%8e%e9%9b%b6%e5%85%a5%e9%97%a8%e7%b3%bb%e5%88%97%ef%bc%88%e5%8d%81%e4%b8%80%ef%bc%89%ef%bc%9aqt%e4%ba%8b%e4%bb%b6%e6%9c%ba%e5%88%b6%e8%af%a6%e8%a7%a3-%e4%bb%8eqevent","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/110105.html","title":{"rendered":"\u300aQt\u4ece\u96f6\u5165\u95e8\u7cfb\u5217\uff08\u5341\u4e00\uff09\uff1aQt\u4e8b\u4ef6\u673a\u5236\u8be6\u89e3\u2014\u2014\u4eceQEvent\u5230\u9f20\u6807\u3001\u952e\u76d8\u4e0e\u5b9a\u65f6\u5668\u4e8b\u4ef6\u300b"},"content":{"rendered":"<p>Qt\u4f5c\u4e3a\u4e3b\u6d41GUI\u5f00\u53d1\u6846\u67b6&#xff0c;\u5176\u6838\u5fc3\u4ea4\u4e92\u80fd\u529b&#xff0c;\u5168\u90fd\u67b6\u5728\u4e8b\u4ef6\u673a\u5236\u8fd9\u6839\u9aa8\u5934\u4e0a\u3002\u4f60\u5e73\u65f6\u70b9\u7684\u6309\u94ae\u3001\u6572\u7684\u6587\u672c\u3001\u62d6\u7684\u7a97\u53e3&#xff0c;\u80cc\u540e\u65e0\u4e00\u4f8b\u5916&#xff0c;\u90fd\u662f\u64cd\u4f5c\u7cfb\u7edf\u5148\u4ea7\u751f\u4e8b\u4ef6&#xff0c;\u518d\u7531Qt\u5c01\u88c5\u597d&#xff0c;\u9012\u5230\u5e94\u7528\u7a0b\u5e8f\u624b\u91cc\u3002\u7edd\u5927\u591a\u6570\u573a\u666f\u4e0b&#xff0c;\u4fe1\u53f7\u69fd\u8db3\u591f\u597d\u7528&#xff0c;\u70b9\u4e00\u4e0b\u3001\u54cd\u4e00\u4e0b&#xff0c;\u8f7b\u677e\u641e\u5b9a\u3002\u53ef\u4e00\u65e6\u8981\u505a\u9ad8\u5ea6\u81ea\u5b9a\u4e49\u7684\u4ea4\u4e92&#xff0c;\u6bd4\u5982\u7ed9\u6309\u94ae\u52a0\u60ac\u505c\u52a8\u753b\u3001\u5168\u5c40\u62e6\u622a\u952e\u76d8\u5feb\u6377\u952e\u3001\u9f20\u6807\u62d6\u62fd\u753b\u56fe\u3001\u7cbe\u51c6\u63a7\u5236\u5b9a\u65f6\u5668&#xff0c;\u4fe1\u53f7\u69fd\u5c31\u6709\u70b9\u529b\u4e0d\u4ece\u5fc3\u4e86\u3002\u8fd9\u65f6\u5019&#xff0c;\u5fc5\u987b\u5f80\u4e0b\u6c89\u4e00\u5c42&#xff0c;\u5230\u4e8b\u4ef6\u673a\u5236\u7684\u5730\u76d8\u4e0a\u52a8\u624b\u3002<\/p>\n<p>\u672c\u6587\u4f1a\u628aQt\u4e8b\u4ef6\u673a\u5236\u7684\u5b8c\u6574\u77e5\u8bc6\u4f53\u7cfb\u7cfb\u7edf\u68b3\u7406\u4e00\u904d&#xff1a;\u5148\u4ece\u4e8b\u4ef6\u4e0e\u4fe1\u53f7\u69fd\u7684\u672c\u8d28\u5173\u7cfb\u5207\u5165&#xff0c;\u518d\u9010\u4e00\u62c6\u89e3\u5e38\u89c1\u4e8b\u4ef6\u7684\u5904\u7406\u65b9\u6cd5\u3001\u4ee3\u7801\u5b9e\u73b0\u548c\u6ce8\u610f\u4e8b\u9879&#xff0c;\u6700\u540e\u63ed\u5f00\u4e8b\u4ef6\u5206\u53d1\u5668\u7684\u5de5\u4f5c\u539f\u7406\u3002\u6240\u6709\u5185\u5bb9\u90fd\u914d\u7740\u5b9e\u6218\u6848\u4f8b&#xff0c;\u786e\u4fdd\u4f60\u8bfb\u5b8c\u65e2\u80fd\u770b\u61c2\u5e95\u5c42\u903b\u8f91&#xff0c;\u53c8\u80fd\u76f4\u63a5\u628a\u4ee3\u7801\u642c\u8fdb\u9879\u76ee\u91cc\u7528\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1021\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260925150920-6ab68ea0979ff.png\" width=\"838\" \/><\/p>\n<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E4%B8%80%E3%80%81%E4%BA%8B%E4%BB%B6%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5-toc\" style=\"margin-left:80px\">\u4e00\u3001\u8ba4\u8bc6Qt\u4e8b\u4ef6\u673a\u5236\u2014\u2014\u4e8b\u4ef6\u4e0e\u4fe1\u53f7\u69fd\u6709\u4ec0\u4e48\u5173\u7cfb<\/p>\n<p id=\"1.1%20%E4%BA%8B%E4%BB%B6%E4%B8%8E%E4%BF%A1%E5%8F%B7%E6%A7%BD%E7%9A%84%E6%9C%AC%E8%B4%A8%E5%85%B3%E7%B3%BB-toc\" style=\"margin-left:120px\">1.1 \u4e8b\u4ef6\u4e0e\u4fe1\u53f7\u69fd\u2014\u2014\u4e24\u5957\u673a\u5236\u7a76\u7adf\u6709\u4ec0\u4e48\u5173\u7cfb<\/p>\n<p id=\"1.2%20QEvent%20%E7%B1%BB%E4%BD%93%E7%B3%BB-toc\" style=\"margin-left:120px\">1.2 QEvent\u2014\u2014Qt\u4e8b\u4ef6\u7684\u57fa\u7840\u7c7b\u578b\u4f53\u7cfb<\/p>\n<p id=\"1.3%20%E4%BA%8B%E4%BB%B6%E7%9A%84%E6%A0%B8%E5%BF%83%E5%A4%84%E7%90%86%E6%9C%BA%E5%88%B6-toc\" style=\"margin-left:120px\">1.3 \u4e00\u4e2a\u4e8b\u4ef6\u662f\u5982\u4f55\u88abQt\u5904\u7406\u7684<\/p>\n<p id=\"%E4%BA%8C%E3%80%81%E9%BC%A0%E6%A0%87%E4%BA%8B%E4%BB%B6%E8%AF%A6%E8%A7%A3-toc\" style=\"margin-left:80px\">\u4e8c\u3001\u9f20\u6807\u4e8b\u4ef6\u2014\u2014\u4ece\u8fdb\u5165\u7a97\u53e3\u5230\u6eda\u8f6e\u64cd\u4f5c<\/p>\n<p id=\"2.1%20%E9%BC%A0%E6%A0%87%E8%BF%9B%E5%85%A5%E4%B8%8E%E7%A6%BB%E5%BC%80%E4%BA%8B%E4%BB%B6-toc\" style=\"margin-left:120px\">2.1 \u9f20\u6807\u8fdb\u5165\u4e0e\u79bb\u5f00\u2014\u2014\u6355\u83b7\u9f20\u6807\u7ecf\u8fc7\u7a97\u53e3\u7684\u72b6\u6001\u53d8\u5316<\/p>\n<p id=\"2.1.1%20%E5%87%BD%E6%95%B0%E5%8E%9F%E5%9E%8B-toc\" style=\"margin-left:160px\">2.1.1 \u4e8b\u4ef6\u51fd\u6570\u539f\u578b<\/p>\n<p id=\"2.1.2%20%E5%AE%8C%E6%95%B4%E5%AE%9E%E7%8E%B0%E6%AD%A5%E9%AA%A4-toc\" style=\"margin-left:160px\">2.1.2 \u4ece\u91cd\u5199\u51fd\u6570\u5230\u5b8c\u6574\u5b9e\u73b0<\/p>\n<p id=\"2.2%20%E9%BC%A0%E6%A0%87%E7%82%B9%E5%87%BB%E4%BA%8B%E4%BB%B6-toc\" style=\"margin-left:120px\">2.2 \u9f20\u6807\u70b9\u51fb\u2014\u2014\u5224\u65ad\u6309\u4e0b\u4e86\u54ea\u4e2a\u6309\u952e<\/p>\n<p id=\"2.2.1%20%E5%87%BD%E6%95%B0%E5%8E%9F%E5%9E%8B%E4%B8%8E%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:160px\">2.2.1 \u51fd\u6570\u539f\u578b\u4e0e\u53c2\u6570\u89e3\u6790<\/p>\n<p id=\"2.2.2%20%E9%BC%A0%E6%A0%87%E6%8C%89%E9%94%AE%E7%B1%BB%E5%9E%8B%E5%88%A4%E6%96%AD-toc\" style=\"margin-left:160px\">2.2.2 \u5982\u4f55\u5224\u65ad\u9f20\u6807\u6309\u952e\u7c7b\u578b<\/p>\n<p id=\"2.2.3%20%E5%AE%9E%E7%8E%B0%E4%BB%A3%E7%A0%81-toc\" style=\"margin-left:160px\">2.2.3 \u9f20\u6807\u70b9\u51fb\u4e8b\u4ef6\u7684\u5b8c\u6574\u5b9e\u73b0<\/p>\n<p id=\"2.3%20%E9%BC%A0%E6%A0%87%E9%87%8A%E6%94%BE%E4%B8%8E%E5%8F%8C%E5%87%BB%E4%BA%8B%E4%BB%B6-toc\" style=\"margin-left:120px\">2.3 \u9f20\u6807\u91ca\u653e\u4e0e\u53cc\u51fb\u4e8b\u4ef6<\/p>\n<p id=\"2.3.1%20%E9%BC%A0%E6%A0%87%E9%87%8A%E6%94%BE%E4%BA%8B%E4%BB%B6-toc\" style=\"margin-left:160px\">2.3.1 \u9f20\u6807\u91ca\u653e\u4e8b\u4ef6\u7684\u5904\u7406<\/p>\n<p id=\"2.3.2%20%E9%BC%A0%E6%A0%87%E5%8F%8C%E5%87%BB%E4%BA%8B%E4%BB%B6-toc\" style=\"margin-left:160px\">2.3.2 \u9f20\u6807\u53cc\u51fb\u4e8b\u4ef6\u7684\u5904\u7406<\/p>\n<p id=\"2.3.3%20%E9%87%8D%E8%A6%81%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9-toc\" style=\"margin-left:160px\">2.3.3 \u9f20\u6807\u91ca\u653e\u4e0e\u53cc\u51fb\u4e2d\u7684\u6ce8\u610f\u4e8b\u9879<\/p>\n<p id=\"2.4%20%E9%BC%A0%E6%A0%87%E7%A7%BB%E5%8A%A8%E4%BA%8B%E4%BB%B6-toc\" style=\"margin-left:120px\">2.4 \u9f20\u6807\u79fb\u52a8\u4e8b\u4ef6\u2014\u2014\u9ed8\u8ba4\u884c\u4e3a\u4e0e\u9f20\u6807\u8ffd\u8e2a<\/p>\n<p id=\"2.4.1%20%E9%BB%98%E8%AE%A4%E8%A1%8C%E4%B8%BA%E4%B8%8E%E9%BC%A0%E6%A0%87%E8%BF%BD%E8%B8%AA-toc\" style=\"margin-left:160px\">2.4.1 \u9ed8\u8ba4\u9f20\u6807\u79fb\u52a8\u884c\u4e3a\u4e0e\u9f20\u6807\u8ffd\u8e2a<\/p>\n<p id=\"2.4.2%20%E5%AE%9E%E7%8E%B0%E4%BB%A3%E7%A0%81-toc\" style=\"margin-left:160px\">2.4.2 \u9f20\u6807\u79fb\u52a8\u4e8b\u4ef6\u7684\u5b9e\u73b0<\/p>\n<p id=\"2.5%20%E9%BC%A0%E6%A0%87%E6%BB%9A%E8%BD%AE%E4%BA%8B%E4%BB%B6-toc\" style=\"margin-left:120px\">2.5 \u9f20\u6807\u6eda\u8f6e\u4e8b\u4ef6\u2014\u2014\u6839\u636e\u6eda\u52a8\u8ddd\u79bb\u5904\u7406\u64cd\u4f5c<\/p>\n<p id=\"2.5.1%20%E5%87%BD%E6%95%B0%E5%8E%9F%E5%9E%8B%E4%B8%8Edelta()%E6%96%B9%E6%B3%95-toc\" style=\"margin-left:160px\">2.5.1 \u51fd\u6570\u539f\u578b\u4e0edelta()\u65b9\u6cd5<\/p>\n<p id=\"2.5.2%20%E7%B4%AF%E8%AE%A1%E6%BB%9A%E5%8A%A8%E8%B7%9D%E7%A6%BB%E5%AE%9E%E7%8E%B0-toc\" style=\"margin-left:160px\">2.5.2 \u901a\u8fc7\u7d2f\u8ba1\u6eda\u52a8\u8ddd\u79bb\u5b9e\u73b0\u6eda\u8f6e\u6548\u679c<\/p>\n<p id=\"%E4%B8%89%E3%80%81%E9%94%AE%E7%9B%98%E4%BA%8B%E4%BB%B6%E8%AF%A6%E8%A7%A3-toc\" style=\"margin-left:80px\">\u4e09\u3001\u952e\u76d8\u4e8b\u4ef6\u2014\u2014\u4ece\u6309\u952e\u8bc6\u522b\u5230\u5feb\u6377\u952e<\/p>\n<p id=\"3.1%20%E9%94%AE%E7%9B%98%E4%BA%8B%E4%BB%B6%E7%9A%84%E8%A7%A6%E5%8F%91%E6%9D%A1%E4%BB%B6-toc\" style=\"margin-left:120px\">3.1 \u952e\u76d8\u4e8b\u4ef6\u5728\u4ec0\u4e48\u6761\u4ef6\u4e0b\u89e6\u53d1<\/p>\n<p id=\"3.2%20%E5%8D%95%E4%B8%AA%E6%8C%89%E9%94%AE%E7%9A%84%E6%8D%95%E8%8E%B7%E4%B8%8E%E5%88%A4%E6%96%AD-toc\" style=\"margin-left:120px\">3.2 \u5982\u4f55\u6355\u83b7\u5e76\u5224\u65ad\u5355\u4e2a\u6309\u952e<\/p>\n<p id=\"3.3%20%E7%BB%84%E5%90%88%E9%94%AE%EF%BC%88%E5%BF%AB%E6%8D%B7%E9%94%AE%EF%BC%89%E7%9A%84%E5%A4%84%E7%90%86-toc\" style=\"margin-left:120px\">3.3 \u7ec4\u5408\u952e\u4e0e\u5feb\u6377\u952e\u7684\u5904\u7406\u65b9\u5f0f<\/p>\n<p id=\"3.4%20%E4%B8%8EQShortcut%E7%9A%84%E5%AF%B9%E6%AF%94-toc\" style=\"margin-left:120px\">3.4 \u952e\u76d8\u4e8b\u4ef6\u4e0eQShortcut\u6709\u4ec0\u4e48\u533a\u522b<\/p>\n<p id=\"%E5%9B%9B%E3%80%81%E5%AE%9A%E6%97%B6%E5%99%A8%E4%BA%8B%E4%BB%B6%E8%AF%A6%E8%A7%A3-toc\" style=\"margin-left:80px\">\u56db\u3001\u5b9a\u65f6\u5668\u4e8b\u4ef6\u2014\u2014QTimerEvent\u7684\u4f7f\u7528<\/p>\n<p id=\"4.1%20QTimerEvent%E7%9A%84%E4%BD%BF%E7%94%A8-toc\" style=\"margin-left:120px\">4.1 QTimerEvent\u7684\u57fa\u672c\u4f7f\u7528\u65b9\u5f0f<\/p>\n<p id=\"4.2%20%E5%AE%9A%E6%97%B6%E5%99%A8%E4%BA%8B%E4%BB%B6%E7%9A%84%E5%85%B3%E9%94%AE%E5%87%BD%E6%95%B0%E4%B8%8E%E5%B7%A5%E4%BD%9C%E6%96%B9%E5%BC%8F-toc\" style=\"margin-left:120px\">4.2 \u5b9a\u65f6\u5668\u4e8b\u4ef6\u7684\u5173\u952e\u51fd\u6570\u4e0e\u5de5\u4f5c\u65b9\u5f0f<\/p>\n<p id=\"4.2.1%20%E6%A0%B8%E5%BF%83%E5%87%BD%E6%95%B0-toc\" style=\"margin-left:160px\">4.2.1 \u6838\u5fc3\u51fd\u6570\u4e0e\u8c03\u7528\u65b9\u5f0f<\/p>\n<p id=\"4.2.2%20%E5%AE%9A%E6%97%B6%E5%99%A8%20ID%20%E7%9A%84%E4%BD%9C%E7%94%A8-toc\" style=\"margin-left:160px\">4.2.2 \u5b9a\u65f6\u5668ID\u2014\u2014\u5982\u4f55\u533a\u5206\u4e0d\u540c\u5b9a\u65f6\u5668<\/p>\n<p id=\"4.2.3%20%E5%80%92%E8%AE%A1%E6%97%B6%E5%8A%9F%E8%83%BD%E5%AE%8C%E6%95%B4%E5%AE%9E%E7%8E%B0-toc\" style=\"margin-left:160px\">4.2.3 \u4f7f\u7528\u5b9a\u65f6\u5668\u5b9e\u73b0\u5b8c\u6574\u5012\u8ba1\u65f6\u529f\u80fd<\/p>\n<p id=\"4.3%20QTimer%20%E4%B8%8E%20QTimerEvent%20%E7%9A%84%E5%AF%B9%E6%AF%94-toc\" style=\"margin-left:120px\">4.3 QTimer\u4e0eQTimerEvent\u2014\u2014\u4e24\u79cd\u5b9a\u65f6\u65b9\u5f0f\u6709\u4ec0\u4e48\u533a\u522b<\/p>\n<p id=\"%E4%BA%94%E3%80%81%E7%AA%97%E5%8F%A3%E4%BA%8B%E4%BB%B6%E8%AF%A6%E8%A7%A3-toc\" style=\"margin-left:80px\">\u4e94\u3001\u7a97\u53e3\u4e8b\u4ef6\u2014\u2014\u7a97\u53e3\u53d1\u751f\u53d8\u5316\u65f6\u4f1a\u6536\u5230\u4ec0\u4e48\u4e8b\u4ef6<\/p>\n<p id=\"5.1%20%E7%AA%97%E5%8F%A3%E7%A7%BB%E5%8A%A8%E4%BA%8B%E4%BB%B6%20moveEvent-toc\" style=\"margin-left:120px\">5.1 moveEvent&#xff1a;\u5904\u7406\u7a97\u53e3\u79fb\u52a8<\/p>\n<p id=\"5.2%20%E7%AA%97%E5%8F%A3%E5%A4%A7%E5%B0%8F%E6%94%B9%E5%8F%98%E4%BA%8B%E4%BB%B6%20resizeEvent-toc\" style=\"margin-left:120px\">5.2 resizeEvent&#xff1a;\u5904\u7406\u7a97\u53e3\u5927\u5c0f\u53d8\u5316<\/p>\n<p id=\"%E5%85%AD%E3%80%81%E4%BA%8B%E4%BB%B6%E5%88%86%E5%8F%91%E5%99%A8%E7%AE%80%E4%BB%8B-toc\" style=\"margin-left:80px\">\u516d\u3001\u4e8b\u4ef6\u5206\u53d1\u5668\u2014\u2014Qt\u5982\u4f55\u628a\u4e8b\u4ef6\u4ea4\u7ed9\u5bf9\u8c61<\/p>\n<p id=\"6.1%20%E4%BA%8B%E4%BB%B6%E5%88%86%E5%8F%91%E5%99%A8%E7%9A%84%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86-toc\" style=\"margin-left:120px\">6.1 \u4e8b\u4ef6\u5206\u53d1\u5668\u7684\u57fa\u672c\u5de5\u4f5c\u539f\u7406<\/p>\n<p id=\"6.2%20event()%E5%87%BD%E6%95%B0%E7%9A%84%E4%BD%9C%E7%94%A8-toc\" style=\"margin-left:120px\">6.2 event()\u51fd\u6570\u2014\u2014\u7edf\u4e00\u5904\u7406\u4e8b\u4ef6\u7684\u5165\u53e3<\/p>\n<p id=\"%E5%85%A8%E6%96%87%E6%80%BB%E7%BB%93-toc\" style=\"margin-left:80px\">\u4e03\u3001\u4e8b\u4ef6\u673a\u5236\u603b\u7ed3<\/p>\n<p id=\"%E7%BB%93%E5%B0%BE-toc\" style=\"margin-left:80px\">\u7ed3\u5c3e<\/p>\n<hr id=\"hr-toc\" \/>\n<h4 id=\"%E4%B8%80%E3%80%81%E4%BA%8B%E4%BB%B6%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5\" style=\"background-color:transparent\">\u4e00\u3001\u8ba4\u8bc6Qt\u4e8b\u4ef6\u673a\u5236\u2014\u2014\u4e8b\u4ef6\u4e0e\u4fe1\u53f7\u69fd\u6709\u4ec0\u4e48\u5173\u7cfb<\/h4>\n<h5 id=\"1.1%20%E4%BA%8B%E4%BB%B6%E4%B8%8E%E4%BF%A1%E5%8F%B7%E6%A7%BD%E7%9A%84%E6%9C%AC%E8%B4%A8%E5%85%B3%E7%B3%BB\">1.1 \u4e8b\u4ef6\u4e0e\u4fe1\u53f7\u69fd\u2014\u2014\u4e24\u5957\u673a\u5236\u7a76\u7adf\u6709\u4ec0\u4e48\u5173\u7cfb<\/h5>\n<p>\u7528\u6237\u4e0d\u7ba1\u505a\u4ec0\u4e48&#xff0c;\u70b9\u9f20\u6807\u3001\u6572\u952e\u76d8\u3001\u62d6\u7a97\u53e3&#xff0c;\u90fd\u4f1a\u5148\u4ea7\u751f\u4e00\u4e2a\u64cd\u4f5c\u7cfb\u7edf\u7ea7\u522b\u7684\u4e8b\u4ef6\u3002Qt\u62ff\u5230\u8fd9\u4e9b\u539f\u751f\u4e8b\u4ef6&#xff0c;\u505a\u4e86\u7b2c\u4e00\u5c42\u5c01\u88c5&#xff0c;\u642d\u51fa\u4e86\u81ea\u5df1\u7684\u4e8b\u4ef6\u4f53\u7cfb\u3002\u4f46\u5149\u6709\u4e8b\u4ef6\u8fd8\u4e0d\u591f&#xff0c;\u4e3a\u4e86\u8ba9\u5927\u5bb6\u5199\u4ee3\u7801\u66f4\u7701\u5fc3&#xff0c;Qt \u53c8\u5728\u6b64\u57fa\u7840\u4e0a\u505a\u4e86\u7b2c\u4e8c\u5c42\u5c01\u88c5&#xff0c;\u8fd9\u624d\u6709\u4e86\u6211\u4eec\u719f\u6089\u7684\u4fe1\u53f7\u69fd\u3002<\/p>\n<p>\u672c\u8d28\u5173\u7cfb\u5c31\u4e00\u53e5\u8bdd&#xff1a;\u4fe1\u53f7\u69fd\u662f\u4e8b\u4ef6\u7684\u8fdb\u4e00\u6b65\u5c01\u88c5&#xff0c;\u4e8b\u4ef6\u662f\u4fe1\u53f7\u69fd\u7684\u5e95\u5c42\u652f\u6491\u3002<\/p>\n<p>\u62ff\u6309\u94ae\u7684clicked()\u4fe1\u53f7\u6765\u8bf4&#xff0c;\u5b83\u672c\u8d28\u4e0a\u5c31\u662fmousePressEvent\u548cmouseReleaseEvent\u4e24\u4e2a\u4e8b\u4ef6\u7ec4\u5408\u51fa\u6765\u7684\u4ea7\u7269\u3002\u6309\u4e0b\u3001\u677e\u5f00&#xff0c;\u4e24\u6b65\u51d1\u9f50&#xff0c;\u4fe1\u53f7\u624d\u53d1\u5f97\u51fa\u6765\u3002<\/p>\n<p>\u4f7f\u7528\u573a\u666f&#xff0c;\u4e5f\u5206\u4e24\u62e8&#xff1a;<\/p>\n<ul>\n<li>\n<p>90%\u4ee5\u4e0a\u7684\u5e38\u89c4\u4ea4\u4e92&#xff0c;\u4fe1\u53f7\u69fd\u5c31\u591f\u7528\u4e86&#xff0c;\u4ee3\u7801\u7b80\u6d01&#xff0c;\u7ef4\u62a4\u4e5f\u7701\u5fc3\u3002<\/p>\n<\/li>\n<li>\n<p>\u78b0\u4e0aQt\u6ca1\u63d0\u4f9b\u73b0\u6210\u4fe1\u53f7&#xff0c;\u6216\u8005\u9700\u8981\u9ad8\u5ea6\u81ea\u5b9a\u4e49\u7684\u4ea4\u4e92\u903b\u8f91\u65f6&#xff0c;\u5c31\u5f97\u76f4\u63a5\u628a\u4e8b\u4ef6\u673a\u5236\u642c\u51fa\u6765\u3002<\/p>\n<\/li>\n<li>\n<p>\u4e8b\u4ef6\u673a\u5236\u7ed9\u5f00\u53d1\u8005\u7559\u4e86\u66f4\u6df1\u7684\u5b9a\u5236\u7a7a\u95f4&#xff0c;\u4fe1\u53f7\u69fd\u641e\u4e0d\u5b9a\u7684\u6d3b\u513f&#xff0c;\u5b83\u80fd\u63a5\u3002<\/p>\n<\/li>\n<\/ul>\n<h5 id=\"1.2%20QEvent%20%E7%B1%BB%E4%BD%93%E7%B3%BB\">1.2 QEvent\u2014\u2014Qt\u4e8b\u4ef6\u7684\u57fa\u7840\u7c7b\u578b\u4f53\u7cfb<\/h5>\n<p>Qt\u91cc\u6240\u6709\u4e8b\u4ef6&#xff0c;\u8ffd\u6839\u6eaf\u6e90&#xff0c;\u90fd\u7ee7\u627f\u81ea\u540c\u4e00\u4e2a\u57fa\u7c7bQEvent\u3002\u4e0d\u540c\u7684\u4e8b\u4ef6\u7c7b\u578b&#xff0c;\u7531\u5404\u81ea\u7684\u5b50\u7c7b\u6765\u625b&#xff0c;\u6bcf\u4e2a\u4e8b\u4ef6\u5bf9\u8c61\u8eab\u4e0a&#xff0c;\u90fd\u80cc\u7740\u8fd9\u6b21\u4ea4\u4e92\u7684\u8be6\u7ec6\u60c5\u62a5\u3002<\/p>\n<p>\u4e0b\u9762\u8fd9\u5f20\u8868&#xff0c;\u628a\u6838\u5fc3\u4e8b\u4ef6\u5b50\u7c7b\u548c\u5b83\u4eec\u5bf9\u5e94\u7684\u573a\u666f\u3001\u643a\u5e26\u7684\u5173\u952e\u4fe1\u606f&#xff0c;\u4e00\u5e76\u5217\u6e05\u695a&#xff1a;<\/p>\n<table>\n<tr>\u4e8b\u4ef6\u5b50\u7c7b\u89e6\u53d1\u573a\u666f\u643a\u5e26\u7684\u6838\u5fc3\u4fe1\u606f<\/tr>\n<tbody>\n<tr>\n<td>QMouseEvent<\/td>\n<td>\u9f20\u6807\u6309\u4e0b\u3001\u79fb\u52a8\u3001\u677e\u5f00<\/td>\n<td>\u5750\u6807\u4f4d\u7f6e\u3001\u6309\u4e0b\u7684\u6309\u952e\u3001\u5168\u5c40\/\u5c40\u90e8\u5750\u6807<\/td>\n<\/tr>\n<tr>\n<td>QKeyEvent<\/td>\n<td>\u952e\u76d8\u6309\u952e\u6309\u4e0b\u3001\u677e\u5f00<\/td>\n<td>\u6309\u952e\u7f16\u7801\u3001\u4fee\u9970\u952e&#xff08;Ctrl\/Shift \u7b49&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>QTimerEvent<\/td>\n<td>\u5b9a\u65f6\u5668\u5230\u70b9<\/td>\n<td>\u5b9a\u65f6\u5668ID<\/td>\n<\/tr>\n<tr>\n<td>QWheelEvent<\/td>\n<td>\u9f20\u6807\u6eda\u8f6e\u6eda\u52a8<\/td>\n<td>\u6eda\u52a8\u8ddd\u79bb\u3001\u6eda\u52a8\u65b9\u5411<\/td>\n<\/tr>\n<tr>\n<td>QPaintEvent<\/td>\n<td>\u7a97\u53e3\u9700\u8981\u91cd\u7ed8<\/td>\n<td>\u91cd\u7ed8\u533a\u57df<\/td>\n<\/tr>\n<tr>\n<td>QMoveEvent<\/td>\n<td>\u7a97\u53e3\u4f4d\u7f6e\u79fb\u52a8<\/td>\n<td>\u65b0\u65e7\u4f4d\u7f6e\u5750\u6807<\/td>\n<\/tr>\n<tr>\n<td>QResizeEvent<\/td>\n<td>\u7a97\u53e3\u5927\u5c0f\u6539\u53d8<\/td>\n<td>\u65b0\u65e7\u5c3a\u5bf8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6bcf\u4e2a\u4e8b\u4ef6\u5b50\u7c7b&#xff0c;\u90fd\u5e26\u7740\u81ea\u5df1\u4e13\u5c5e\u7684\u90a3\u4efd\u4fe1\u606f\u3002\u4f60\u5904\u7406\u9f20\u6807\u4e8b\u4ef6&#xff0c;\u80fd\u62ff\u5230\u5750\u6807&#xff1b;\u5904\u7406\u952e\u76d8\u4e8b\u4ef6&#xff0c;\u80fd\u62ff\u5230\u952e\u7801&#xff1b;\u5904\u7406\u91cd\u7ed8\u4e8b\u4ef6&#xff0c;\u80fd\u62ff\u5230\u9700\u8981\u5237\u65b0\u7684\u533a\u57df\u3002\u5404\u53f8\u5176\u804c&#xff0c;\u4e92\u4e0d\u8d8a\u754c\u3002<\/p>\n<h5 id=\"1.3%20%E4%BA%8B%E4%BB%B6%E7%9A%84%E6%A0%B8%E5%BF%83%E5%A4%84%E7%90%86%E6%9C%BA%E5%88%B6\">1.3 \u4e00\u4e2a\u4e8b\u4ef6\u662f\u5982\u4f55\u88abQt\u5904\u7406\u7684<\/h5>\n<p>Qt\u91cc\u5904\u7406\u4e8b\u4ef6&#xff0c;\u6838\u5fc3\u62db\u6570\u5c31\u4e00\u4e2a&#xff1a;\u91cd\u5199\u7236\u7c7b\u7684\u865a\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u3002 \u8fd9\u5957\u73a9\u6cd5&#xff0c;\u9760\u7684\u6b63\u662fC&#043;&#043;\u7684\u591a\u6001\u673a\u5236\u3002<\/p>\n<p>\u6d41\u7a0b\u8d70\u4e0b\u6765&#xff0c;\u56db\u6b65&#xff1a;<\/p>\n<li>\n<p>\u521b\u5efa\u81ea\u5b9a\u4e49\u7c7b&#xff0c;\u7ee7\u627f\u81eaQt\u63d0\u4f9b\u7684\u6807\u51c6\u63a7\u4ef6\u7c7b&#xff0c;\u6bd4\u5982QLabel\u3001QWidget\u3001QPushButton\u3002<\/p>\n<\/li>\n<li>\n<p>\u91cd\u5199\u7236\u7c7b\u5bf9\u5e94\u7684\u865a\u4e8b\u4ef6\u5904\u7406\u51fd\u6570&#xff0c;\u50cfenterEvent()\u3001mousePressEvent()\u8fd9\u4e9b\u3002<\/p>\n<\/li>\n<li>\n<p>\u628a UI \u8bbe\u8ba1\u5668\u91cc\u62d6\u653e\u7684\u6807\u51c6\u63a7\u4ef6&#xff0c;\u63d0\u5347\u4e3a\u81ea\u5b9a\u4e49\u7c7b\u7684\u5b9e\u4f8b\u3002<\/p>\n<\/li>\n<li>\n<p>\u4e8b\u4ef6\u4e00\u89e6\u53d1&#xff0c;Qt\u901a\u8fc7\u591a\u6001\u673a\u5236&#xff0c;\u81ea\u52a8\u8c03\u7528\u4f60\u91cd\u5199\u7684\u90a3\u4e2a\u51fd\u6570\u3002<\/p>\n<\/li>\n<p>\u542c\u8d77\u6765\u7b80\u5355&#xff0c;\u4f46\u6709\u4e2a\u5751\u5fc5\u987b\u76ef\u6b7b&#xff1a;\u91cd\u5199\u4e8b\u4ef6\u51fd\u6570\u65f6&#xff0c;\u51fd\u6570\u540d\u3001\u53c2\u6570\u7c7b\u578b\u3001\u53c2\u6570\u4e2a\u6570&#xff0c;\u5fc5\u987b\u8ddf\u7236\u7c7b\u4e00\u6a21\u4e00\u6837&#xff0c;\u5426\u5219\u591a\u6001\u6839\u672c\u89e6\u53d1\u4e0d\u4e86\u3002 \u5dee\u4e00\u4e2a\u5b57\u3001\u9519\u4e00\u4e2a\u7c7b\u578b&#xff0c;\u7f16\u8bd1\u5668\u4e0d\u62a5\u9519&#xff0c;\u4f46\u4f60\u7684\u51fd\u6570\u5c31\u662f\u4e2a\u6446\u8bbe&#xff0c;\u4e8b\u4ef6\u6765\u4e86\u4e5f\u4e0d\u7406\u4f60\u3002<\/p>\n<p>\u8fd8\u6709\u4e00\u70b9&#xff0c;\u7279\u522b\u5bb9\u6613\u683d&#xff1a;\u6ce8\u610f\u51fd\u6570\u540d\u7684\u5927\u5c0f\u5199\u3002 Qt\u7684\u4e8b\u4ef6\u51fd\u6570&#xff0c;\u7edf\u7edf\u4ee5\u5c0f\u5199\u5b57\u6bcd\u5f00\u5934\u3002mousePressEvent\u4e0d\u80fd\u5199\u6210MousePressEvent&#xff0c;enterEvent\u4e5f\u4e0d\u80fd\u5199\u6210EnterEvent\u3002\u5927\u5199\u4e00\u5f00&#xff0c;\u591a\u6001\u5c31\u8ddf\u4f60\u65e0\u7f18\u4e86\u3002<\/p>\n<h4 id=\"%E4%BA%8C%E3%80%81%E9%BC%A0%E6%A0%87%E4%BA%8B%E4%BB%B6%E8%AF%A6%E8%A7%A3\">\u4e8c\u3001\u9f20\u6807\u4e8b\u4ef6\u2014\u2014\u4ece\u8fdb\u5165\u7a97\u53e3\u5230\u6eda\u8f6e\u64cd\u4f5c<\/h4>\n<p>\u9f20\u6807\u4e8b\u4ef6&#xff0c;\u662fGUI\u5f00\u53d1\u91cc\u51fa\u573a\u7387\u6700\u9ad8\u7684\u4e00\u7c7b\u4e8b\u4ef6\u3002\u9f20\u6807\u7684\u8fdb\u5165\u3001\u79bb\u5f00\u3001\u70b9\u51fb\u3001\u79fb\u52a8\u3001\u6eda\u8f6e\u2026\u2026\u7edf\u7edf\u5f52\u5b83\u7ba1\u3002<\/p>\n<h5 id=\"2.1%20%E9%BC%A0%E6%A0%87%E8%BF%9B%E5%85%A5%E4%B8%8E%E7%A6%BB%E5%BC%80%E4%BA%8B%E4%BB%B6\">2.1 \u9f20\u6807\u8fdb\u5165\u4e0e\u79bb\u5f00\u2014\u2014\u6355\u83b7\u9f20\u6807\u7ecf\u8fc7\u7a97\u53e3\u7684\u72b6\u6001\u53d8\u5316<\/h5>\n<p>\u8fd9\u4e24\u4e2a\u4e8b\u4ef6&#xff0c;\u4e13\u95e8\u76ef\u7740\u9f20\u6807\u5149\u6807\u4ec0\u4e48\u65f6\u5019\u6e9c\u8fdb\u63a7\u4ef6\u533a\u57df\u3001\u4ec0\u4e48\u65f6\u5019\u53c8\u6e9c\u51fa\u53bb\u3002\u60ac\u505c\u6548\u679c\u3001\u63d0\u793a\u4fe1\u606f&#xff0c;\u591a\u534a\u9760\u5b83\u4eec\u5b9e\u73b0\u3002<\/p>\n<h6 id=\"2.1.1%20%E5%87%BD%E6%95%B0%E5%8E%9F%E5%9E%8B\">2.1.1 \u4e8b\u4ef6\u51fd\u6570\u539f\u578b<\/h6>\n<p>\/\/ \u9f20\u6807\u8fdb\u5165\u63a7\u4ef6\u65f6\u89e6\u53d1<br \/>\n[virtual protected] void QWidget::enterEvent(QEvent *event);<\/p>\n<p>\/\/ \u9f20\u6807\u79bb\u5f00\u63a7\u4ef6\u65f6\u89e6\u53d1<br \/>\n[virtual protected] void QWidget::leaveEvent(QEvent *event); <\/p>\n<p>\u91cd\u5199\u7684\u65f6\u5019&#xff0c;\u8bb0\u5f97\u4fdd\u6301\u51fd\u6570\u7b7e\u540d\u4e00\u81f4&#xff1a;virtual protected\u4e0d\u80fd\u5c11&#xff0c;\u53c2\u6570\u7c7b\u578b\u4e5f\u5f97\u5bf9\u4e0a\u3002Qt5\u91cc&#xff0c;enterEvent\u7684\u53c2\u6570\u662fQEvent *&#xff1b;\u5230\u4e86Qt6&#xff0c;\u5b83\u6362\u6210\u4e86QEnterEvent *\u3002\u7248\u672c\u4e0d\u540c&#xff0c;\u7ec6\u8282\u6709\u53d8&#xff0c;\u5199\u4ee3\u7801\u65f6\u7559\u610f\u4e00\u4e0b\u624b\u5934\u7684Qt\u7248\u672c\u3002<\/p>\n<h6 id=\"2.1.2%20%E5%AE%8C%E6%95%B4%E5%AE%9E%E7%8E%B0%E6%AD%A5%E9%AA%A4\">2.1.2 \u4ece\u91cd\u5199\u51fd\u6570\u5230\u5b8c\u6574\u5b9e\u73b0<\/h6>\n<p>\u5149\u770b\u539f\u578b\u4e0d\u8fc7\u763e&#xff0c;\u6211\u4eec\u76f4\u63a5\u52a8\u624b\u505a\u4e00\u4e2a\u3002\u6574\u4e2a\u6d41\u7a0b\u5206\u4e09\u6b65&#xff1a;\u5199\u81ea\u5b9a\u4e49\u7c7b\u3001\u5b9e\u73b0\u4e8b\u4ef6\u51fd\u6570\u3001\u628a\u63a7\u4ef6\u201c\u63d0\u62d4\u201d\u6210\u81ea\u5df1\u7684\u7c7b\u3002<\/p>\n<p>\u7b2c\u4e00\u6b65&#xff1a;\u521b\u5efa\u81ea\u5b9a\u4e49Label\u7c7b&#xff0c;\u7ee7\u627f\u81eaQLabel<\/p>\n<p>\u5934\u6587\u4ef6label.h&#xff1a;<\/p>\n<p>#ifndef LABEL_H<br \/>\n#define LABEL_H<br \/>\n#include &lt;QLabel&gt;<\/p>\n<p>class Label : public QLabel<br \/>\n{<br \/>\n    Q_OBJECT<br \/>\npublic:<br \/>\n    Label(QWidget *parent &#061; nullptr);<\/p>\n<p>protected:<br \/>\n    void enterEvent(QEvent *event) override;<br \/>\n    void leaveEvent(QEvent *event) override;<br \/>\n};<\/p>\n<p>#endif \/\/ LABEL_H <\/p>\n<p>\u7b2c\u4e8c\u6b65&#xff1a;\u5728\u6e90\u6587\u4ef6\u91cc\u91cd\u5199\u4e8b\u4ef6\u51fd\u6570<\/p>\n<p>label.cpp&#xff1a;<\/p>\n<p>#include &#034;label.h&#034;<br \/>\n#include &lt;QDebug&gt;<\/p>\n<p>Label::Label(QWidget *parent) : QLabel(parent)<br \/>\n{<br \/>\n}<\/p>\n<p>void Label::enterEvent(QEvent *event)<br \/>\n{<br \/>\n    (void)event; \/\/ \u6d88\u6389\u201c\u672a\u4f7f\u7528\u53c2\u6570\u201d\u7684\u8b66\u544a<br \/>\n    qDebug() &lt;&lt; &#034;\u9f20\u6807\u8fdb\u5165Label\u533a\u57df&#034;;<br \/>\n}<\/p>\n<p>void Label::leaveEvent(QEvent *event)<br \/>\n{<br \/>\n    (void)event;<br \/>\n    qDebug() &lt;&lt; &#034;\u9f20\u6807\u79bb\u5f00Label\u533a\u57df&#034;;<br \/>\n} <\/p>\n<p>\u8fd9\u91cc\u6709\u4e2a\u5c0f\u7ec6\u8282&#xff1a;(void)event;\u8fd9\u884c\u4e0d\u662f\u591a\u4f59\u7684\u3002\u53c2\u6570\u6ca1\u7528\u4e0a&#xff0c;\u7f16\u8bd1\u5668\u4f1a\u5520\u53e8&#xff0c;\u52a0\u8fd9\u4e00\u53e5&#xff0c;\u76f8\u5f53\u4e8e\u544a\u8bc9\u5b83&#xff1a;\u201c\u6211\u77e5\u9053\u6709\u8fd9\u4e48\u4e2a\u4e1c\u897f&#xff0c;\u6545\u610f\u4e0d\u7528&#xff0c;\u522b\u5ff5\u4e86\u3002\u201d<\/p>\n<p>\u7b2c\u4e09\u6b65&#xff1a;\u628aUI\u91cc\u7684\u6807\u51c6\u63a7\u4ef6&#xff0c;\u63d0\u5347\u6210\u81ea\u5b9a\u4e49\u7c7b<\/p>\n<li>\u5728UI\u8bbe\u8ba1\u5668\u91cc\u62d6\u4e00\u4e2aQLabel\u51fa\u6765\u3002<\/li>\n<li>\u53f3\u952e\u70b9\u5b83&#xff0c;\u9009\u201c\u63d0\u5347\u4e3a\u201d\u3002<\/li>\n<li>\u5f39\u7a97\u91cc&#xff0c;\u57fa\u7c7b\u540d\u79f0\u586bQLabel&#xff0c;\u63d0\u5347\u7684\u7c7b\u540d\u79f0\u586bLabel&#xff0c;\u5934\u6587\u4ef6\u586blabel.h\u3002<\/li>\n<li>\u70b9\u201c\u6dfb\u52a0\u201d&#xff0c;\u518d\u70b9\u201c\u63d0\u5347\u201d\u3002<\/li>\n<p>\u641e\u5b9a\u3002\u6b64\u65f6\u754c\u9762\u4e0a\u90a3\u4e2aQLabel&#xff0c;\u9aa8\u5b50\u91cc\u5df2\u7ecf\u6362\u6210\u4e86\u6211\u4eec\u81ea\u5b9a\u4e49\u7684Label\u7c7b\u3002\u8fd0\u884c\u7a0b\u5e8f&#xff0c;\u9f20\u6807\u4e00\u8fdb\u4e00\u51fa&#xff0c;\u63a7\u5236\u53f0\u5c31\u4f1a\u4e56\u4e56\u6253\u5370\u51fa\u5bf9\u5e94\u7684\u63d0\u793a\u3002\u4e00\u4e2a\u6700\u7b80\u5355\u7684\u81ea\u5b9a\u4e49\u4e8b\u4ef6\u5904\u7406&#xff0c;\u5c31\u8fd9\u4e48\u8dd1\u901a\u4e86\u3002<\/p>\n<h5 id=\"2.2%20%E9%BC%A0%E6%A0%87%E7%82%B9%E5%87%BB%E4%BA%8B%E4%BB%B6\">2.2 \u9f20\u6807\u70b9\u51fb\u2014\u2014\u5224\u65ad\u6309\u4e0b\u4e86\u54ea\u4e2a\u6309\u952e<\/h5>\n<p>\u8fd9\u4e2a\u4e8b\u4ef6\u4e13\u95e8\u6293\u9f20\u6807\u6309\u952e\u7684\u201c\u6309\u4e0b\u201d\u64cd\u4f5c\u3002\u70b9\u54ea\u513f\u4e86\u3001\u6309\u7684\u662f\u54ea\u4e2a\u952e&#xff0c;\u5b83\u90fd\u7ed9\u4f60\u8bb0\u7740\u3002<\/p>\n<h6 id=\"2.2.1%20%E5%87%BD%E6%95%B0%E5%8E%9F%E5%9E%8B%E4%B8%8E%E5%8F%82%E6%95%B0\">2.2.1 \u51fd\u6570\u539f\u578b\u4e0e\u53c2\u6570\u89e3\u6790<\/h6>\n<p>[virtual protected] void QWidget::mousePressEvent(QMouseEvent *event); <\/p>\n<p>\u53c2\u6570QMouseEvent* event\u8eab\u4e0a&#xff0c;\u80cc\u7740\u8fd9\u6b21\u70b9\u51fb\u7684\u5168\u90e8\u4fe1\u606f&#xff1a;<\/p>\n<ul>\n<li>event-&gt;x() \/ event-&gt;y()&#xff1a;\u70b9\u51fb\u4f4d\u7f6e\u76f8\u5bf9\u4e8e\u63a7\u4ef6\u5de6\u4e0a\u89d2\u7684\u5c40\u90e8\u5750\u6807\u3002<\/li>\n<li>event-&gt;globalX() \/ event-&gt;globalY()&#xff1a;\u70b9\u51fb\u4f4d\u7f6e\u76f8\u5bf9\u4e8e\u5c4f\u5e55\u5de6\u4e0a\u89d2\u7684\u5168\u5c40\u5750\u6807\u3002<\/li>\n<li>event-&gt;button()&#xff1a;\u8fd4\u56de\u6309\u4e0b\u7684\u9f20\u6807\u6309\u952e&#xff0c;\u7c7b\u578b\u662fQt::MouseButton\u679a\u4e3e\u3002<\/li>\n<\/ul>\n<p>\u5c40\u90e8\u5750\u6807\u548c\u5168\u5c40\u5750\u6807&#xff0c;\u542c\u7740\u5dee\u4e0d\u591a&#xff0c;\u7528\u8d77\u6765\u5929\u5dee\u5730\u522b\u3002\u63a7\u4ef6\u5185\u90e8\u5904\u7406&#xff0c;\u7528\u5c40\u90e8&#xff1b;\u8981\u8ddf\u5c4f\u5e55\u6216\u5176\u4ed6\u7a97\u53e3\u6253\u4ea4\u9053&#xff0c;\u5c31\u5f97\u5207\u5230\u5168\u5c40\u3002<\/p>\n<h6 id=\"2.2.2%20%E9%BC%A0%E6%A0%87%E6%8C%89%E9%94%AE%E7%B1%BB%E5%9E%8B%E5%88%A4%E6%96%AD\">2.2.2 \u5982\u4f55\u5224\u65ad\u9f20\u6807\u6309\u952e\u7c7b\u578b<\/h6>\n<p>Qt::MouseButton\u679a\u4e3e\u628a\u652f\u6301\u7684\u6309\u952e\u5168\u5217\u4e86\u51fa\u6765&#xff1a;<\/p>\n<p>Qt::LeftButton    \/\/ \u5de6\u952e 0x00000001<br \/>\nQt::RightButton   \/\/ \u53f3\u952e 0x00000002<br \/>\nQt::MiddleButton  \/\/ \u4e2d\u952e&#xff08;\u6eda\u8f6e&#xff09;0x00000004<br \/>\nQt::BackButton    \/\/ \u4fa7\u952e\u540e\u9000 0x00000008<br \/>\nQt::ForwardButton \/\/ \u4fa7\u952e\u524d\u8fdb 0x00000010 <\/p>\n<p>\u6ce8\u610f\u5230\u4e86\u5417&#xff1f;\u6bcf\u4e2a\u6309\u952e\u5bf9\u5e94\u7684\u503c&#xff0c;\u90fd\u662f2\u7684\u5e42&#xff0c;1\u30012\u30014\u30018\u300116\u3002\u8fd9\u4e0d\u662f\u5de7\u5408\u3002\u75282\u7684\u5e42\u505a\u503c&#xff0c;\u5c31\u80fd\u9760\u6309\u4f4d\u4e0e&amp;\u6765\u540c\u65f6\u5224\u65ad\u591a\u4e2a\u6309\u952e\u7684\u7ec4\u5408&#xff0c;\u4e00\u4e2a\u6574\u6570\u88c5\u4e0b\u6240\u6709\u72b6\u6001&#xff0c;\u5e72\u51c0\u5229\u843d\u3002<\/p>\n<h6 id=\"2.2.3%20%E5%AE%9E%E7%8E%B0%E4%BB%A3%E7%A0%81\">2.2.3 \u9f20\u6807\u70b9\u51fb\u4e8b\u4ef6\u7684\u5b8c\u6574\u5b9e\u73b0<\/h6>\n<p>\u5728\u81ea\u5b9a\u4e49Label\u7c7b\u91cc&#xff0c;\u628a\u9f20\u6807\u6309\u4e0b\u4e8b\u4ef6\u8865\u4e0a\u3002<\/p>\n<p>\u5148\u5728label.h\u91cc\u52a0\u58f0\u660e&#xff1a;<\/p>\n<p>protected:<br \/>\n    void mousePressEvent(QMouseEvent *event) override; <\/p>\n<p>\u7136\u540e\u5728label.cpp\u91cc\u5b9e\u73b0&#xff1a;<\/p>\n<p>#include &lt;QMouseEvent&gt;<\/p>\n<p>void Label::mousePressEvent(QMouseEvent *event)<br \/>\n{<br \/>\n    \/\/ \u5224\u65ad\u6309\u4e0b\u7684\u6309\u952e<br \/>\n    if (event-&gt;button() &#061;&#061; Qt::LeftButton) {<br \/>\n        qDebug() &lt;&lt; &#034;\u6309\u4e0b\u9f20\u6807\u5de6\u952e&#034;;<br \/>\n    } else if (event-&gt;button() &#061;&#061; Qt::RightButton) {<br \/>\n        qDebug() &lt;&lt; &#034;\u6309\u4e0b\u9f20\u6807\u53f3\u952e&#034;;<br \/>\n    } else if (event-&gt;button() &#061;&#061; Qt::MiddleButton) {<br \/>\n        qDebug() &lt;&lt; &#034;\u6309\u4e0b\u9f20\u6807\u4e2d\u952e&#034;;<br \/>\n    }<\/p>\n<p>    \/\/ \u8f93\u51fa\u5750\u6807\u4fe1\u606f<br \/>\n    qDebug() &lt;&lt; &#034;\u5c40\u90e8\u5750\u6807&#xff1a;&#034; &lt;&lt; event-&gt;x() &lt;&lt; &#034;,&#034; &lt;&lt; event-&gt;y();<br \/>\n    qDebug() &lt;&lt; &#034;\u5168\u5c40\u5750\u6807&#xff1a;&#034; &lt;&lt; event-&gt;globalX() &lt;&lt; &#034;,&#034; &lt;&lt; event-&gt;globalY();<br \/>\n} <\/p>\n<p>\u8fd9\u6bb5\u903b\u8f91\u5f88\u76f4\u767d&#xff1a;\u5148\u770bevent-&gt;button()\u8fd4\u56de\u7684\u662f\u54ea\u4e2a\u952e&#xff0c;\u5206\u95e8\u522b\u7c7b\u6253\u65e5\u5fd7&#xff1b;\u518d\u628a\u8fd9\u6b21\u70b9\u51fb\u7684\u5c40\u90e8\u5750\u6807\u548c\u5168\u5c40\u5750\u6807\u90fd\u4eae\u51fa\u6765\u3002<\/p>\n<p>\u6709\u4e00\u4e2a\u7ec6\u8282\u503c\u5f97\u7559\u610f&#xff1a;event-&gt;button()\u5728\u9f20\u6807\u6309\u4e0b\u4e8b\u4ef6\u91cc&#xff0c;\u8fd4\u56de\u7684\u662f\u5f53\u524d\u8fd9\u4e00\u6b21\u89e6\u53d1\u7684\u90a3\u4e2a\u6309\u952e\u3002\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u5982\u679c\u4f60\u540c\u65f6\u6309\u4e0b\u4e86\u5de6\u53f3\u952e&#xff0c;\u6bcf\u6b21\u89e6\u53d1\u53ea\u4f1a\u8fd4\u56de\u5176\u4e2d\u4e00\u4e2a\u3002\u800c\u5982\u679c\u4f60\u60f3\u5224\u65ad\u201c\u6b64\u523b\u6709\u54ea\u4e9b\u952e\u88ab\u6309\u7740\u201d&#xff0c;\u90a3\u5f97\u7528event-&gt;buttons()&#xff0c;\u6ce8\u610f\u672b\u5c3e\u591a\u4e86\u4e00\u4e2as&#xff0c;\u8fd4\u56de\u7684\u662f\u4e00\u7ec4\u6309\u952e\u7684\u4f4d\u63a9\u7801\u3002\u4e00\u4e2a\u662f\u5355\u6570&#xff0c;\u4e00\u4e2a\u662f\u590d\u6570&#xff0c;\u522b\u641e\u6df7\u4e86\u3002<\/p>\n<h5 id=\"2.3%20%E9%BC%A0%E6%A0%87%E9%87%8A%E6%94%BE%E4%B8%8E%E5%8F%8C%E5%87%BB%E4%BA%8B%E4%BB%B6\">2.3 \u9f20\u6807\u91ca\u653e\u4e0e\u53cc\u51fb\u4e8b\u4ef6<\/h5>\n<h6 id=\"2.3.1%20%E9%BC%A0%E6%A0%87%E9%87%8A%E6%94%BE%E4%BA%8B%E4%BB%B6\">2.3.1 \u9f20\u6807\u91ca\u653e\u4e8b\u4ef6\u7684\u5904\u7406<\/h6>\n<p>\u6309\u952e\u677e\u624b\u7684\u90a3\u4e00\u523b&#xff0c;\u5c31\u8f6e\u5230\u5b83\u767b\u573a\u4e86\u3002<\/p>\n<p>\/\/ \u51fd\u6570\u539f\u578b<br \/>\n[virtual protected] void QWidget::mouseReleaseEvent(QMouseEvent *event);<\/p>\n<p>\/\/ \u5b9e\u73b0\u4ee3\u7801<br \/>\nvoid Label::mouseReleaseEvent(QMouseEvent *event)<br \/>\n{<br \/>\n    if (event-&gt;button() &#061;&#061; Qt::LeftButton) {<br \/>\n        qDebug() &lt;&lt; &#034;\u91ca\u653e\u9f20\u6807\u5de6\u952e&#034;;<br \/>\n    } else if (event-&gt;button() &#061;&#061; Qt::RightButton) {<br \/>\n        qDebug() &lt;&lt; &#034;\u91ca\u653e\u9f20\u6807\u53f3\u952e&#034;;<br \/>\n    }<br \/>\n} <\/p>\n<p>\u8ddf\u6309\u4e0b\u4e8b\u4ef6\u4e00\u6837&#xff0c;event-&gt;button()\u544a\u8bc9\u4f60\u677e\u624b\u7684\u662f\u54ea\u4e2a\u952e\u3002\u6309\u4e0b\u3001\u91ca\u653e&#xff0c;\u6210\u5bf9\u51fa\u73b0&#xff0c;\u4e00\u6b21\u5b8c\u6574\u7684\u70b9\u51fb\u624d\u7b97\u753b\u4e0a\u53e5\u53f7\u3002<\/p>\n<h6 id=\"2.3.2%20%E9%BC%A0%E6%A0%87%E5%8F%8C%E5%87%BB%E4%BA%8B%E4%BB%B6\">2.3.2 \u9f20\u6807\u53cc\u51fb\u4e8b\u4ef6\u7684\u5904\u7406<\/h6>\n<p>\u53cc\u51fb\u6709\u81ea\u5df1\u4e13\u5c5e\u7684\u4e8b\u4ef6\u5904\u7406\u51fd\u6570&#xff0c;\u4e0d\u7528\u4f60\u81ea\u5df1\u53bb\u6570\u70b9\u51fb\u6b21\u6570\u3002<\/p>\n<p>\/\/ \u51fd\u6570\u539f\u578b<br \/>\n[virtual protected] void QWidget::mouseDoubleClickEvent(QMouseEvent *event);<\/p>\n<p>\/\/ \u5b9e\u73b0\u4ee3\u7801<br \/>\nvoid Label::mouseDoubleClickEvent(QMouseEvent *event)<br \/>\n{<br \/>\n    if (event-&gt;button() &#061;&#061; Qt::LeftButton) {<br \/>\n        qDebug() &lt;&lt; &#034;\u53cc\u51fb\u9f20\u6807\u5de6\u952e&#034;;<br \/>\n    }<br \/>\n} <\/p>\n<h6 id=\"2.3.3%20%E9%87%8D%E8%A6%81%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9\">2.3.3 \u9f20\u6807\u91ca\u653e\u4e0e\u53cc\u51fb\u4e2d\u7684\u6ce8\u610f\u4e8b\u9879<\/h6>\n<p>\u8fd9\u91cc\u6709\u4e2a\u5f88\u5bb9\u6613\u8e29\u5751\u7684\u5730\u65b9&#xff1a;\u53cc\u51fb\u4e0d\u662f\u72ec\u7acb\u52a8\u4f5c\u3002 \u7cfb\u7edf\u4f1a\u5148\u7ed9\u4f60\u6765\u4e24\u8f6e\u5355\u51fb\u7684\u6309\u4e0b\u548c\u91ca\u653e&#xff0c;\u7136\u540e\u624d\u8f6e\u5230\u53cc\u51fb\u4e8b\u4ef6\u767b\u573a\u3002\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u4e00\u6b21\u53cc\u51fb&#xff0c;\u80cc\u540e\u5176\u5b9e\u85cf\u7740\u56db\u6b21\u4e8b\u4ef6&#xff1a;\u6309\u4e0b\u3001\u91ca\u653e\u3001\u6309\u4e0b\u3001\u91ca\u653e&#xff0c;\u6700\u540e\u624d\u8865\u4e00\u4e2a\u53cc\u51fb\u3002<\/p>\n<p>\u5982\u679c\u4f60\u540c\u65f6\u5b9e\u73b0\u4e86\u5355\u51fb\u548c\u53cc\u51fb\u903b\u8f91&#xff0c;\u5c31\u5f97\u7559\u795e\u51b2\u7a81\u4e86\u3002\u7528\u6237\u53cc\u51fb\u7684\u65f6\u5019&#xff0c;\u5355\u51fb\u903b\u8f91\u4e5f\u4f1a\u88ab\u89e6\u53d1\u4e24\u6b21\u3002\u60f3\u533a\u5206\u6e05\u695a&#xff0c;\u5e38\u89c1\u7684\u505a\u6cd5\u662f&#xff1a;\u7528\u5b9a\u65f6\u5668\u5ef6\u8fdf\u5224\u65ad\u3002 \u5355\u51fb\u4e4b\u540e\u4e0d\u6025\u7740\u6267\u884c&#xff0c;\u5148\u7b49\u4e00\u5c0f\u4f1a\u513f&#xff0c;\u5982\u679c\u5728\u5ef6\u8fdf\u671f\u95f4\u6765\u4e86\u7b2c\u4e8c\u6b21\u70b9\u51fb&#xff0c;\u90a3\u5c31\u5f53\u53cc\u51fb\u5904\u7406&#xff1b;\u5982\u679c\u6ca1\u6765&#xff0c;\u624d\u628a\u5b83\u5f53\u6210\u5355\u51fb\u3002\u591a\u7b49\u90a3\u4e48\u4e00\u4e0b&#xff0c;\u903b\u8f91\u5c31\u5206\u6e05\u4e86\u3002<\/p>\n<h5 id=\"2.4%20%E9%BC%A0%E6%A0%87%E7%A7%BB%E5%8A%A8%E4%BA%8B%E4%BB%B6\" style=\"background-color:transparent\">2.4 \u9f20\u6807\u79fb\u52a8\u4e8b\u4ef6\u2014\u2014\u9ed8\u8ba4\u884c\u4e3a\u4e0e\u9f20\u6807\u8ffd\u8e2a<\/h5>\n<p>\u8fd9\u4e2a\u4e8b\u4ef6\u8d1f\u8d23\u5b9e\u65f6\u6c47\u62a5\u9f20\u6807\u7684\u79fb\u52a8\u4f4d\u7f6e\u3002\u62d6\u62fd\u3001\u7ed8\u5236\u8fd9\u7c7b\u9700\u8981\u201c\u8ddf\u7740\u9f20\u6807\u8d70\u201d\u7684\u529f\u80fd&#xff0c;\u5168\u9760\u5b83\u6491\u7740\u3002<\/p>\n<h6 id=\"2.4.1%20%E9%BB%98%E8%AE%A4%E8%A1%8C%E4%B8%BA%E4%B8%8E%E9%BC%A0%E6%A0%87%E8%BF%BD%E8%B8%AA\">2.4.1 \u9ed8\u8ba4\u9f20\u6807\u79fb\u52a8\u884c\u4e3a\u4e0e\u9f20\u6807\u8ffd\u8e2a<\/h6>\n<p>Qt\u9ed8\u8ba4\u5e76\u4e0d\u8ffd\u8e2a\u9f20\u6807\u79fb\u52a8\u3002\u9f20\u6807\u5728\u63a7\u4ef6\u4e0a\u6ed1\u6765\u6ed1\u53bb&#xff0c;\u53ea\u8981\u6ca1\u6309\u4e0b\u6309\u952e&#xff0c;mouseMoveEvent\u5c31\u4e00\u58f0\u4e0d\u542d\u3002\u53ea\u6709\u6309\u952e\u5904\u4e8e\u6309\u4e0b\u72b6\u6001\u65f6&#xff0c;\u5b83\u624d\u80af\u5e72\u6d3b\u3002\u5982\u679c\u4f60\u60f3\u8ba9\u9f20\u6807\u4e0d\u6309\u952e\u4e5f\u80fd\u88ab\u8ffd\u8e2a&#xff0c;\u6bd4\u5982\u505a\u60ac\u505c\u63d0\u793a\u3001\u753b\u677f\u9884\u89c8&#xff0c;\u90a3\u5c31\u5f97\u624b\u52a8\u6253\u5f00\u5f00\u5173\u3002\u5728\u63a7\u4ef6\u7684\u6784\u9020\u51fd\u6570\u91cc\u8865\u4e0a\u8fd9\u4e48\u4e00\u53e5&#xff1a;<\/p>\n<p>this-&gt;setMouseTracking(true); <\/p>\n<p>\u52a0\u4e0a\u5b83&#xff0c;\u9f20\u6807\u7684\u6bcf\u4e00\u6b21\u632a\u52a8\u90fd\u4f1a\u89e6\u53d1\u4e8b\u4ef6&#xff0c;\u5b9e\u65f6\u611f\u7acb\u523b\u62c9\u6ee1\u3002\u4e0d\u5c11\u4eba\u7b2c\u4e00\u6b21\u7528mouseMoveEvent \u65f6\u4f1a\u7eb3\u95f7&#xff1a;\u600e\u4e48\u4e0d\u52a8&#xff1f;\u516b\u6210\u5c31\u662f\u5fd8\u4e86\u6253\u5f00\u8fd9\u4e2a\u5f00\u5173\u3002<\/p>\n<h6 id=\"2.4.2%20%E5%AE%9E%E7%8E%B0%E4%BB%A3%E7%A0%81\" style=\"background-color:transparent\">2.4.2 \u9f20\u6807\u79fb\u52a8\u4e8b\u4ef6\u7684\u5b9e\u73b0<\/h6>\n<p>\u5148\u5728widget.h\u91cc\u58f0\u660e&#xff1a;<\/p>\n<p>protected:<br \/>\n    void mouseMoveEvent(QMouseEvent *event) override; <\/p>\n<p>\u518d\u5230widget.cpp\u91cc\u5b9e\u73b0&#xff0c;\u6784\u9020\u51fd\u6570\u4e2d\u8bb0\u5f97\u628a\u9f20\u6807\u8ffd\u8e2a\u6253\u5f00&#xff1a;<\/p>\n<p>Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)<br \/>\n{<br \/>\n    ui-&gt;setupUi(this);<br \/>\n    this-&gt;setMouseTracking(true); \/\/ \u5f00\u542f\u9f20\u6807\u8ffd\u8e2a<br \/>\n}<\/p>\n<p>void Widget::mouseMoveEvent(QMouseEvent *event)<br \/>\n{<br \/>\n    qDebug() &lt;&lt; &#034;\u9f20\u6807\u79fb\u52a8\u5230&#xff1a;&#034; &lt;&lt; event-&gt;x() &lt;&lt; &#034;,&#034; &lt;&lt; event-&gt;y();<br \/>\n} <\/p>\n<p>\u6709\u4e00\u4ef6\u4e8b\u5f97\u7559\u5fc3&#xff1a;\u9f20\u6807\u79fb\u52a8\u4e8b\u4ef6\u7684\u89e6\u53d1\u9891\u7387\u975e\u5e38\u9ad8&#xff0c;\u9f20\u6807\u8f7b\u8f7b\u4e00\u5212&#xff0c;\u56de\u8c03\u53ef\u80fd\u5c31\u88ab\u62c9\u8d77\u6765\u51e0\u5341\u4e0a\u767e\u6b21\u3002\u8981\u662f\u5904\u7406\u51fd\u6570\u91cc\u585e\u4e86\u590d\u6742\u903b\u8f91&#xff0c;\u7a0b\u5e8f\u5f88\u5bb9\u6613\u88ab\u62d6\u5361\u3002\u6240\u4ee5&#xff0c;\u80fd\u7cbe\u7b80\u5c31\u7cbe\u7b80&#xff0c;\u80fd\u7f13\u5b58\u5c31\u7f13\u5b58&#xff0c;\u522b\u8ba9\u9ad8\u9891\u4e8b\u4ef6\u53d8\u6210\u6027\u80fd\u9ed1\u6d1e\u3002<\/p>\n<h5 id=\"2.5%20%E9%BC%A0%E6%A0%87%E6%BB%9A%E8%BD%AE%E4%BA%8B%E4%BB%B6\">2.5 \u9f20\u6807\u6eda\u8f6e\u4e8b\u4ef6\u2014\u2014\u6839\u636e\u6eda\u52a8\u8ddd\u79bb\u5904\u7406\u64cd\u4f5c<\/h5>\n<p>\u9f20\u6807\u6eda\u8f6e\u90a3\u70b9\u52a8\u9759&#xff0c;\u5168\u9760\u8fd9\u4e2a\u4e8b\u4ef6\u6765\u6293\u3002\u7f29\u653e\u3001\u6eda\u52a8\u5217\u8868&#xff0c;\u90fd\u6307\u671b\u5b83\u6765\u611f\u77e5\u3002<\/p>\n<h6 id=\"2.5.1%20%E5%87%BD%E6%95%B0%E5%8E%9F%E5%9E%8B%E4%B8%8Edelta()%E6%96%B9%E6%B3%95\">2.5.1 \u51fd\u6570\u539f\u578b\u4e0edelta()\u65b9\u6cd5<\/h6>\n<p>[virtual protected] void QWidget::wheelEvent(QWheelEvent *event); <\/p>\n<p>event-&gt;delta()\u8fd4\u56de\u6eda\u8f6e\u6eda\u52a8\u7684\u8ddd\u79bb&#xff0c;\u5355\u4f4d\u662f1\/8\u5ea6\u3002<\/p>\n<ul>\n<li>\u5411\u4e0a\u6eda&#xff1a;\u8fd4\u56de\u6b63\u503c&#xff0c;\u901a\u5e38\u4e3a120\u3002<\/li>\n<li>\u5411\u4e0b\u6eda&#xff1a;\u8fd4\u56de\u8d1f\u503c&#xff0c;\u901a\u5e38\u4e3a-120\u3002<\/li>\n<\/ul>\n<h6 id=\"2.5.2%20%E7%B4%AF%E8%AE%A1%E6%BB%9A%E5%8A%A8%E8%B7%9D%E7%A6%BB%E5%AE%9E%E7%8E%B0\">2.5.2 \u901a\u8fc7\u7d2f\u8ba1\u6eda\u52a8\u8ddd\u79bb\u5b9e\u73b0\u6eda\u8f6e\u6548\u679c<\/h6>\n<p>\u5148\u5728widget.h\u91cc\u5907\u4e00\u4e2a\u8ba1\u6570\u5668&#xff1a;<\/p>\n<p>private:<br \/>\n    int totalDelta &#061; 0;<\/p>\n<p>protected:<br \/>\n    void wheelEvent(QWheelEvent *event) override; <\/p>\n<p>\u518d\u5230widget.cpp\u91cc\u5b9e\u73b0&#xff1a;<\/p>\n<p>#include &lt;QWheelEvent&gt;<\/p>\n<p>void Widget::wheelEvent(QWheelEvent *event)<br \/>\n{<br \/>\n    totalDelta &#043;&#061; event-&gt;delta();<br \/>\n    qDebug() &lt;&lt; &#034;\u672c\u6b21\u6eda\u52a8\u8ddd\u79bb&#xff1a;&#034; &lt;&lt; event-&gt;delta();<br \/>\n    qDebug() &lt;&lt; &#034;\u7d2f\u8ba1\u6eda\u52a8\u8ddd\u79bb&#xff1a;&#034; &lt;&lt; totalDelta;<br \/>\n} <\/p>\n<p>\u6bcf\u6eda\u4e00\u4e0b&#xff0c;delta()\u5c31\u628a\u8fd9\u6b21\u7684\u6eda\u52a8\u91cf\u62a5\u51fa\u6765&#xff0c;\u987a\u624b\u7d2f\u52a0\u5230totalDelta\u4e0a\u3002\u4e00\u6b21\u4e00\u8bb0&#xff0c;\u79ef\u5c11\u6210\u591a&#xff0c;\u6eda\u4e86\u591a\u5c11&#xff0c;\u5fc3\u91cc\u6709\u6570\u3002<\/p>\n<p>\u987a\u5e26\u63d0\u4e00\u53e5&#xff1a;\u5728Qt6\u91cc&#xff0c;delta()\u5df2\u7ecf\u9000\u4f11&#xff0c;\u6362\u6210\u4e86angleDelta()\u3002\u6838\u5fc3\u601d\u8def\u6ca1\u53d8&#xff0c;\u53ea\u662fAPI\u6362\u4e86\u4e2a\u540d\u5b57\u3002\u5982\u679c\u9879\u76ee\u8de8\u7248\u672c&#xff0c;\u8fd9\u70b9\u5f97\u7559\u4e2a\u5fc3\u3002<\/p>\n<h4 id=\"%E4%B8%89%E3%80%81%E9%94%AE%E7%9B%98%E4%BA%8B%E4%BB%B6%E8%AF%A6%E8%A7%A3\">\u4e09\u3001\u952e\u76d8\u4e8b\u4ef6\u2014\u2014\u4ece\u6309\u952e\u8bc6\u522b\u5230\u5feb\u6377\u952e<\/h4>\n<p>\u952e\u76d8\u4e8b\u4ef6&#xff0c;\u4e13\u95e8\u6536\u62fe\u7528\u6237\u7684\u952e\u76d8\u8f93\u5165\u3002\u5355\u4e2a\u6309\u952e\u4e5f\u597d&#xff0c;Ctrl\u3001Shift\u8fd9\u79cd\u7ec4\u5408\u952e\u4e5f\u7f62&#xff0c;\u90fd\u5f52\u5b83\u7ba1\u3002<\/p>\n<h5 id=\"3.1%20%E9%94%AE%E7%9B%98%E4%BA%8B%E4%BB%B6%E7%9A%84%E8%A7%A6%E5%8F%91%E6%9D%A1%E4%BB%B6\">3.1 \u952e\u76d8\u4e8b\u4ef6\u5728\u4ec0\u4e48\u6761\u4ef6\u4e0b\u89e6\u53d1<\/h5>\n<p>\u952e\u76d8\u4e8b\u4ef6\u6709\u4e2a\u524d\u63d0&#xff1a;\u63a7\u4ef6\u6216\u7a97\u53e3\u5fc5\u987b\u5904\u4e8e\u6fc0\u6d3b\u72b6\u6001\u3002 \u7126\u70b9\u5728\u4f60\u8fd9\u513f&#xff0c;\u6309\u952e\u624d\u8f6e\u5f97\u5230\u4f60\u63a5\u3002\u7126\u70b9\u8981\u662f\u8dd1\u5230\u522b\u7684\u63a7\u4ef6\u6216\u8005\u522b\u7684\u7a0b\u5e8f\u90a3\u513f\u53bb\u4e86&#xff0c;\u90a3\u8fd9\u4e9b\u952e\u76d8\u8f93\u5165\u5c31\u8ddf\u4f60\u6ca1\u5173\u7cfb\u4e86&#xff0c;\u5168\u88ab\u4eba\u5bb6\u622a\u8d70\u3002<\/p>\n<h5 id=\"3.2%20%E5%8D%95%E4%B8%AA%E6%8C%89%E9%94%AE%E7%9A%84%E6%8D%95%E8%8E%B7%E4%B8%8E%E5%88%A4%E6%96%AD\">3.2 \u5982\u4f55\u6355\u83b7\u5e76\u5224\u65ad\u5355\u4e2a\u6309\u952e<\/h5>\n<p>\/\/ \u51fd\u6570\u539f\u578b<br \/>\n[virtual protected] void QWidget::keyPressEvent(QKeyEvent *event);<br \/>\n[virtual protected] void QWidget::keyReleaseEvent(QKeyEvent *event); <\/p>\n<p>event-&gt;key()\u8fd4\u56de\u6309\u4e0b\u7684\u6309\u952e\u7f16\u7801&#xff0c;\u5bf9\u5e94\u7684\u662fQt::Key_*\u8fd9\u4e00\u5957\u679a\u4e3e\u3002<\/p>\n<p>\u770b\u5b9e\u73b0\u4ee3\u7801&#xff1a;<\/p>\n<p>#include &lt;QKeyEvent&gt;<\/p>\n<p>void Widget::keyPressEvent(QKeyEvent *event)<br \/>\n{<br \/>\n    qDebug() &lt;&lt; &#034;\u6309\u4e0b\u6309\u952e\u7f16\u7801&#xff1a;&#034; &lt;&lt; event-&gt;key();<\/p>\n<p>    \/\/ \u5224\u65ad\u5177\u4f53\u6309\u952e<br \/>\n    if (event-&gt;key() &#061;&#061; Qt::Key_A) {<br \/>\n        qDebug() &lt;&lt; &#034;\u6309\u4e0b\u4e86A\u952e&#034;;<br \/>\n    } else if (event-&gt;key() &#061;&#061; Qt::Key_Escape) {<br \/>\n        qDebug() &lt;&lt; &#034;\u6309\u4e0b\u4e86ESC\u952e&#034;;<br \/>\n        this-&gt;close(); \/\/ \u6309\u4e0bESC\u5173\u95ed\u7a97\u53e3<br \/>\n    }<br \/>\n} <\/p>\n<p>\u903b\u8f91\u4e0d\u590d\u6742&#xff1a;\u5148\u628a\u6309\u952e\u7f16\u7801\u6253\u51fa\u6765&#xff0c;\u518d\u62ffevent-&gt;key()\u53bb\u8ddf\u5177\u4f53\u7684\u952e\u6bd4\u5bf9\u3002Qt::Key_A\u662fA\u952e&#xff0c;Qt::Key_Escape\u662fESC\u952e&#xff0c;\u4e00\u6bd4\u5bf9\u5c31\u77e5\u9053\u7528\u6237\u6309\u4e86\u54ea\u4e2a\u3002\u4e0a\u9762\u8fd9\u6bb5&#xff0c;ESC\u4e00\u6309&#xff0c;\u7a97\u53e3\u76f4\u63a5\u5173\u6389&#xff0c;\u5e72\u8106\u5229\u843d\u3002<\/p>\n<h5 id=\"3.3%20%E7%BB%84%E5%90%88%E9%94%AE%EF%BC%88%E5%BF%AB%E6%8D%B7%E9%94%AE%EF%BC%89%E7%9A%84%E5%A4%84%E7%90%86\">3.3 \u7ec4\u5408\u952e\u4e0e\u5feb\u6377\u952e\u7684\u5904\u7406\u65b9\u5f0f<\/h5>\n<p>\u5355\u4e2a\u952e\u597d\u529e&#xff0c;\u53ef\u4e00\u65e6\u9047\u4e0aCtrl\u3001Shift\u3001Alt\u8fd9\u4e9b\u4fee\u9970\u952e&#xff0c;\u5c31\u5f97\u6362\u4e2a\u59ff\u52bf\u4e86\u3002\u5149\u9760event-&gt;key()\u53ea\u80fd\u77e5\u9053\u7528\u6237\u6572\u4e86\u54ea\u4e2a\u4e3b\u952e&#xff0c;\u60f3\u77e5\u9053\u4ed6\u6709\u6ca1\u6709\u540c\u65f6\u6309\u7740Ctrl&#xff0c;\u8fd8\u5f97\u770b\u53e6\u4e00\u4e2a\u65b9\u6cd5&#xff1a;event-&gt;modifiers()\u3002<\/p>\n<p>\u5b83\u8fd4\u56de\u7684\u662f\u4fee\u9970\u952e\u7684\u72b6\u6001&#xff0c;\u5bf9\u5e94Qt::KeyboardModifier\u679a\u4e3e&#xff1a;<\/p>\n<ul>\n<li>Qt::ControlModifier&#xff1a;Ctrl \u952e<\/li>\n<li>Qt::ShiftModifier&#xff1a;Shift \u952e<\/li>\n<li>Qt::AltModifier&#xff1a;Alt \u952e<\/li>\n<\/ul>\n<p>\u770b\u4ee3\u7801&#xff0c;\u5904\u7406Ctrl &#043; A&#xff1a;<\/p>\n<p>void Widget::keyPressEvent(QKeyEvent *event)<br \/>\n{<br \/>\n    if (event-&gt;key() &#061;&#061; Qt::Key_A &amp;&amp; event-&gt;modifiers() &#061;&#061; Qt::ControlModifier) {<br \/>\n        qDebug() &lt;&lt; &#034;\u6309\u4e0b\u4e86Ctrl&#043;A\u7ec4\u5408\u952e&#034;;<br \/>\n        \/\/ \u5b9e\u73b0\u5168\u9009\u903b\u8f91<br \/>\n    }<br \/>\n} <\/p>\n<p>\u8fd9\u91cc\u4e24\u4e2a\u6761\u4ef6\u5fc5\u987b\u540c\u65f6\u6210\u7acb&#xff1a;\u4e3b\u952e\u662fA&#xff0c;\u4fee\u9970\u952e\u662fCtrl\u3002\u7f3a\u4e00\u4e2a&#xff0c;\u7ec4\u5408\u952e\u5c31\u4e0d\u6210\u7acb\u3002\u4e24\u4e2a\u6761\u4ef6\u4e00\u5361&#xff0c;Ctrl&#043;A\u5c31\u88ab\u7cbe\u51c6\u6355\u83b7\u4e86&#xff0c;\u540e\u9762\u63a5\u4e0a\u5168\u9009\u903b\u8f91&#xff0c;\u5feb\u6377\u952e\u5c31\u7b97\u843d\u5730\u4e86\u3002<\/p>\n<h5 id=\"3.4%20%E4%B8%8EQShortcut%E7%9A%84%E5%AF%B9%E6%AF%94\">3.4 \u952e\u76d8\u4e8b\u4ef6\u4e0eQShortcut\u6709\u4ec0\u4e48\u533a\u522b<\/h5>\n<p>\u5feb\u6377\u952e\u8fd9\u4e1c\u897f&#xff0c;\u4e0d\u662f\u975e\u5f97\u7528\u952e\u76d8\u4e8b\u4ef6\u786c\u5543\u3002<\/p>\n<p>\u7b80\u5355\u7684\u5feb\u6377\u952e&#xff0c;\u76f4\u63a5\u4e0aQShortcut\u7c7b&#xff0c;\u8d70\u4fe1\u53f7\u69fd\u90a3\u5957&#xff0c;\u4ee3\u7801\u66f4\u77ed&#xff0c;\u5199\u8d77\u6765\u4e5f\u6e05\u723d\u3002\u70b9\u4e00\u4e0b\u3001\u8fde\u4e00\u4e0b&#xff0c;\u903b\u8f91\u5c31\u901a\u4e86\u3002<\/p>\n<p>\u53ef\u8981\u662f\u78b0\u4e0a\u590d\u6742\u7684\u952e\u76d8\u73a9\u6cd5&#xff0c;\u8fde\u7eed\u6309\u952e\u3001\u957f\u6309\u68c0\u6d4b\u3001\u7ec4\u5408\u952e\u5d4c\u5957&#xff0c;\u90a3\u8fd8\u662f\u5f97\u56de\u5230\u952e\u76d8\u4e8b\u4ef6\u4e0a\u6765\u3002\u5b83\u7ed9\u7684\u81ea\u7531\u5ea6\u66f4\u9ad8&#xff0c;\u60f3\u600e\u4e48\u5904\u7406\u5c31\u600e\u4e48\u5904\u7406&#xff0c;\u4e0d\u53d7\u4fe1\u53f7\u69fd\u7684\u6761\u6761\u6846\u6846\u9650\u5236\u3002<\/p>\n<p>\u6240\u4ee5\u9009\u54ea\u4e2a&#xff0c;\u770b\u9700\u6c42&#xff1a;\u56fe\u7701\u4e8b&#xff0c;\u7528QShortcut&#xff1b;\u8981\u6df1\u5ea6\u5b9a\u5236&#xff0c;\u4e0a\u952e\u76d8\u4e8b\u4ef6\u3002<\/p>\n<h4 id=\"%E5%9B%9B%E3%80%81%E5%AE%9A%E6%97%B6%E5%99%A8%E4%BA%8B%E4%BB%B6%E8%AF%A6%E8%A7%A3\">\u56db\u3001\u5b9a\u65f6\u5668\u4e8b\u4ef6\u2014\u2014QTimerEvent\u7684\u4f7f\u7528<\/h4>\n<p>\u5b9a\u65f6\u5668\u8fd9\u4e1c\u897f&#xff0c;\u5c31\u662f\u7528\u6765\u5468\u671f\u6027\u5e72\u6d3b\u7684\u2014\u2014\u505a\u52a8\u753b\u3001\u641e\u5012\u8ba1\u65f6\u3001\u5b9a\u65f6\u5237\u65b0&#xff0c;\u90fd\u79bb\u4e0d\u5f00\u5b83\u3002Qt\u7ed9\u4e86\u4e24\u5957\u65b9\u6848&#xff1a;\u4e00\u5957\u662f\u9ad8\u5c42\u63a5\u53e3QTimer&#xff0c;\u4e00\u5957\u662f\u5e95\u5c42\u4e8b\u4ef6QTimerEvent\u3002<\/p>\n<h5 id=\"4.1%20QTimerEvent%E7%9A%84%E4%BD%BF%E7%94%A8\">4.1 QTimerEvent\u7684\u57fa\u672c\u4f7f\u7528\u65b9\u5f0f<\/h5>\n<p>QTimerEvent\u662fQt\u5b9a\u65f6\u5668\u7684\u5e95\u5c42\u5b9e\u73b0\u3002\u4e0d\u7ba1\u4e0a\u5c42\u600e\u4e48\u5c01\u88c5&#xff0c;\u6240\u6709\u5b9a\u65f6\u5668\u6700\u7ec8\u90fd\u4f1a\u843d\u5230\u8fd9\u4e2a\u4e8b\u4ef6\u4e0a\u3002<\/p>\n<h5 id=\"4.2%20%E5%AE%9A%E6%97%B6%E5%99%A8%E4%BA%8B%E4%BB%B6%E7%9A%84%E5%85%B3%E9%94%AE%E5%87%BD%E6%95%B0%E4%B8%8E%E5%B7%A5%E4%BD%9C%E6%96%B9%E5%BC%8F\">4.2 \u5b9a\u65f6\u5668\u4e8b\u4ef6\u7684\u5173\u952e\u51fd\u6570\u4e0e\u5de5\u4f5c\u65b9\u5f0f<\/h5>\n<h6 id=\"4.2.1%20%E6%A0%B8%E5%BF%83%E5%87%BD%E6%95%B0\">4.2.1 \u6838\u5fc3\u51fd\u6570\u4e0e\u8c03\u7528\u65b9\u5f0f<\/h6>\n<p>int startTimer(int interval);          \/\/ \u5f00\u542f\u5b9a\u65f6\u5668&#xff0c;\u53c2\u6570\u662f\u95f4\u9694\u65f6\u95f4&#xff08;\u6beb\u79d2&#xff09;&#xff0c;\u8fd4\u56de\u552f\u4e00\u7684\u5b9a\u65f6\u5668 ID<br \/>\nvoid killTimer(int id);                \/\/ \u6839\u636e\u5b9a\u65f6\u5668 ID \u505c\u6b62\u5b9a\u65f6\u5668<br \/>\nvoid timerEvent(QTimerEvent *event);   \/\/ \u5b9a\u65f6\u5668\u4e8b\u4ef6\u5904\u7406\u51fd\u6570&#xff0c;\u6240\u6709\u5b9a\u65f6\u5668\u89e6\u53d1\u65f6\u90fd\u4f1a\u8c03\u7528\u5b83 <\/p>\n<p>\u4e09\u4e2a\u51fd\u6570&#xff0c;\u5404\u7ba1\u4e00\u644a&#xff1a;startTimer\u8d1f\u8d23\u751f&#xff0c;killTimer\u8d1f\u8d23\u6740&#xff0c;timerEvent\u8d1f\u8d23\u5e72\u6d3b\u3002\u4e00\u5f00\u4e00\u5173\u4e00\u5904\u7406&#xff0c;\u95ed\u73af\u5c31\u6210\u4e86\u3002<\/p>\n<h6 id=\"4.2.2%20%E5%AE%9A%E6%97%B6%E5%99%A8%20ID%20%E7%9A%84%E4%BD%9C%E7%94%A8\" style=\"background-color:transparent\">4.2.2 \u5b9a\u65f6\u5668ID\u2014\u2014\u5982\u4f55\u533a\u5206\u4e0d\u540c\u5b9a\u65f6\u5668<\/h6>\n<p>\u6bcf\u6b21\u8c03\u7528startTimer&#xff0c;\u5b83\u90fd\u4f1a\u8fd8\u4f60\u4e00\u4e2a\u72ec\u4e00\u65e0\u4e8c\u7684ID\u3002\u8fd9\u4e2aID&#xff0c;\u5c31\u662f\u7528\u6765\u533a\u5206\u4e0d\u540c\u5b9a\u65f6\u5668\u7684\u3002\u5b83\u6709\u70b9\u50cfLinux\u91cc\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff0c;\u90fd\u662f\u4e2a\u6574\u6570&#xff0c;\u90fd\u662f\u8eab\u4efd\u6807\u8bc6&#xff0c;\u4f60\u62ff\u7740\u5b83&#xff0c;\u5c31\u77e5\u9053\u81ea\u5df1\u5728\u8ddf\u8c01\u6253\u4ea4\u9053\u3002<\/p>\n<p>\u7a0b\u5e8f\u91cc\u8981\u662f\u6709\u591a\u4e2a\u5b9a\u65f6\u5668&#xff0c;\u90a3\u5c31\u5fc5\u987b\u5728timerEvent\u91cc\u9760\u8fd9\u4e2aID\u6765\u5224\u65ad&#xff1a;\u8fd9\u6b21\u5230\u5e95\u662f\u54ea\u4e2a\u5b9a\u65f6\u5668\u54cd\u4e86&#xff1f;\u8ba4\u9519\u4e86ID&#xff0c;\u903b\u8f91\u5c31\u4e32\u4e86\u3002\u4e00\u4e2aID\u5bf9\u4e00\u644a\u4e8b&#xff0c;\u5206\u6e05\u695a&#xff0c;\u624d\u4e0d\u4f1a\u4e71\u3002<\/p>\n<h6 id=\"4.2.3%20%E5%80%92%E8%AE%A1%E6%97%B6%E5%8A%9F%E8%83%BD%E5%AE%8C%E6%95%B4%E5%AE%9E%E7%8E%B0\" style=\"background-color:transparent\">4.2.3 \u4f7f\u7528\u5b9a\u65f6\u5668\u5b9e\u73b0\u5b8c\u6574\u5012\u8ba1\u65f6\u529f\u80fd<\/h6>\n<p>\u4ee3\u7801\u4e0d\u590d\u6742&#xff0c;\u4f46\u628a\u5b9a\u65f6\u5668\u7684\u751f\u3001\u7528\u3001\u6740\u4e32\u6210\u4e86\u4e00\u6761\u5b8c\u6574\u7684\u7ebf\u3002\u5148\u770b\u5934\u6587\u4ef6&#xff1a;<\/p>\n<p>\/\/ widget.h<br \/>\nprivate:<br \/>\n    Ui::Widget *ui;<br \/>\n    int timerId; \/\/ \u4fdd\u5b58\u5b9a\u65f6\u5668ID<\/p>\n<p>protected:<br \/>\n    void timerEvent(QTimerEvent *event) override; <\/p>\n<p>\u518d\u770b\u5b9e\u73b0&#xff1a;<\/p>\n<p>\/\/ widget.cpp<br \/>\nWidget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)<br \/>\n{<br \/>\n    ui-&gt;setupUi(this);<\/p>\n<p>    \/\/ LCD \u521d\u59cb\u503c\u8bbe\u4e3a 10<br \/>\n    ui-&gt;lcdNumber-&gt;display(10);<\/p>\n<p>    \/\/ \u5f00\u542f\u4e00\u4e2a 1 \u79d2\u95f4\u9694\u7684\u5b9a\u65f6\u5668<br \/>\n    timerId &#061; this-&gt;startTimer(1000);<br \/>\n}<\/p>\n<p>Widget::~Widget()<br \/>\n{<br \/>\n    delete ui;<br \/>\n}<\/p>\n<p>void Widget::timerEvent(QTimerEvent *event)<br \/>\n{<br \/>\n    \/\/ \u5148\u8ba4\u95e8&#xff1a;\u4e0d\u662f\u6211\u4eec\u7684\u5b9a\u65f6\u5668&#xff0c;\u76f4\u63a5\u5ffd\u7565<br \/>\n    if (event-&gt;timerId() !&#061; this-&gt;timerId) {<br \/>\n        return;<br \/>\n    }<\/p>\n<p>    \/\/ \u770b\u770b LCD \u4e0a\u73b0\u5728\u663e\u793a\u591a\u5c11<br \/>\n    int value &#061; ui-&gt;lcdNumber-&gt;intValue();<\/p>\n<p>    if (value &lt;&#061; 0) {<br \/>\n        \/\/ \u5012\u8ba1\u65f6\u5f52\u96f6&#xff0c;\u505c\u6389\u5b9a\u65f6\u5668&#xff0c;\u6536\u5de5<br \/>\n        this-&gt;killTimer(this-&gt;timerId);<br \/>\n        qDebug() &lt;&lt; &#034;\u5012\u8ba1\u65f6\u7ed3\u675f&#034;;<br \/>\n        return;<br \/>\n    }<\/p>\n<p>    \/\/ \u6570\u5b57\u51cf\u4e00&#xff0c;\u5237\u65b0\u663e\u793a<br \/>\n    value&#8211;;<br \/>\n    ui-&gt;lcdNumber-&gt;display(value);<br \/>\n} <\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u91cc&#xff0c;\u51e0\u4e2a\u52a8\u4f5c\u914d\u5408\u5f97\u5f88\u5e72\u51c0&#xff1a;\u6784\u9020\u51fd\u6570\u91cc\u5f00\u5b9a\u65f6\u5668&#xff0c;timerEvent\u91cc\u5224\u65adID\u3001\u68c0\u67e5\u6570\u503c\u3001\u9012\u51cf\u5237\u65b0&#xff0c;\u5f52\u96f6\u4e4b\u540e\u679c\u65adkillTimer\u6536\u624b\u3002\u6ca1\u6709\u591a\u4f59\u7684\u7ea0\u7f20&#xff0c;\u5012\u8ba1\u65f6\u5c31\u8fd9\u4e48\u4e00\u79d2\u4e00\u79d2\u8d70\u5b8c\u4e86\u3002<\/p>\n<h5 id=\"4.3%20QTimer%20%E4%B8%8E%20QTimerEvent%20%E7%9A%84%E5%AF%B9%E6%AF%94\" style=\"background-color:transparent\">4.3 QTimer\u4e0eQTimerEvent\u2014\u2014\u4e24\u79cd\u5b9a\u65f6\u65b9\u5f0f\u6709\u4ec0\u4e48\u533a\u522b<\/h5>\n<ul>\n<li>QTimer\u662f\u9ad8\u5c42\u63a5\u53e3&#xff0c;\u8d70\u7684\u662f\u4fe1\u53f7\u69fd\u90a3\u4e00\u5957\u3002\u4e00\u4e2a\u5b9a\u65f6\u5668\u5bf9\u5e94\u4e00\u4e2a\u5bf9\u8c61&#xff0c;\u4ee3\u7801\u8bfb\u8d77\u6765\u6e05\u723d&#xff0c;\u7ef4\u62a4\u4e5f\u7701\u5fc3\u3002\u5b9e\u9645\u5f00\u53d1\u91cc&#xff0c;\u5b83\u57fa\u672c\u5c31\u662f\u9996\u9009\u3002<\/li>\n<li>QTimerEvent\u5219\u8e72\u5728\u5e95\u5c42&#xff0c;\u73a9\u7684\u662f\u4e8b\u4ef6\u673a\u5236\u3002\u5b9a\u65f6\u5668ID\u5f97\u81ea\u5df1\u4eb2\u624b\u7ba1&#xff0c;\u591a\u4e2a\u5b9a\u65f6\u5668\u8fd8\u6324\u5728\u540c\u4e00\u4e2a\u5904\u7406\u51fd\u6570\u91cc&#xff0c;\u4ee3\u7801\u76f8\u5bf9\u9ebb\u70e6\u3002\u4f46\u9ebb\u70e6\u4e5f\u6709\u9ebb\u70e6\u7684\u56de\u62a5&#xff0c;\u5b83\u66f4\u7075\u6d3b&#xff0c;\u60f3\u600e\u4e48\u6298\u817e\u90fd\u884c\u3002<\/li>\n<\/ul>\n<h4 id=\"%E4%BA%94%E3%80%81%E7%AA%97%E5%8F%A3%E4%BA%8B%E4%BB%B6%E8%AF%A6%E8%A7%A3\">\u4e94\u3001\u7a97\u53e3\u4e8b\u4ef6\u2014\u2014\u7a97\u53e3\u53d1\u751f\u53d8\u5316\u65f6\u4f1a\u6536\u5230\u4ec0\u4e48\u4e8b\u4ef6<\/h4>\n<p>\u7a97\u53e3\u7684\u4f4d\u7f6e\u632a\u4e86\u3001\u5927\u5c0f\u53d8\u4e86&#xff0c;\u8fd9\u4e9b\u52a8\u9759&#xff0c;\u5168\u5f52\u7a97\u53e3\u4e8b\u4ef6\u6765\u7ba1\u3002\u60f3\u505a\u81ea\u9002\u5e94\u5e03\u5c40\u3001\u60f3\u76ef\u4f4f\u7a97\u53e3\u72b6\u6001\u7684\u4e00\u4e3e\u4e00\u52a8&#xff0c;\u80cc\u540e\u90fd\u5f97\u9760\u5b83\u6765\u6355\u83b7\u3002<\/p>\n<h5 id=\"5.1%20%E7%AA%97%E5%8F%A3%E7%A7%BB%E5%8A%A8%E4%BA%8B%E4%BB%B6%20moveEvent\" style=\"background-color:transparent\">5.1 moveEvent&#xff1a;\u5904\u7406\u7a97\u53e3\u79fb\u52a8<\/h5>\n<p>\u7a97\u53e3\u88ab\u62d6\u52a8\u3001\u4f4d\u7f6e\u53d1\u751f\u53d8\u5316\u7684\u90a3\u4e00\u523b&#xff0c;\u8fd9\u4e2a\u51fd\u6570\u5c31\u4f1a\u88ab\u89e6\u53d1\u3002<\/p>\n<p>\/\/ \u51fd\u6570\u539f\u578b<br \/>\n[virtual protected] void QWidget::moveEvent(QMoveEvent *event); <\/p>\n<p>\u5b9e\u73b0\u4ee3\u7801&#xff1a;<\/p>\n<p>#include &lt;QMoveEvent&gt;<\/p>\n<p>void Widget::moveEvent(QMoveEvent *event)<br \/>\n{<br \/>\n    qDebug() &lt;&lt; &#034;\u7a97\u53e3\u65e7\u4f4d\u7f6e&#xff1a;&#034; &lt;&lt; event-&gt;oldPos();<br \/>\n    qDebug() &lt;&lt; &#034;\u7a97\u53e3\u65b0\u4f4d\u7f6e&#xff1a;&#034; &lt;&lt; event-&gt;pos();<br \/>\n} <\/p>\n<p>event-&gt;oldPos()\u62ff\u5230\u7684\u662f\u79fb\u52a8\u524d\u7684\u5750\u6807&#xff0c;event-&gt;pos()\u5219\u662f\u79fb\u52a8\u540e\u7684\u65b0\u5750\u6807\u3002\u4e00\u65e7\u4e00\u65b0&#xff0c;\u7a97\u53e3\u4ece\u54ea\u513f\u632a\u5230\u54ea\u513f&#xff0c;\u770b\u5f97\u6e05\u6e05\u695a\u695a\u3002<\/p>\n<h5 id=\"5.2%20%E7%AA%97%E5%8F%A3%E5%A4%A7%E5%B0%8F%E6%94%B9%E5%8F%98%E4%BA%8B%E4%BB%B6%20resizeEvent\" style=\"background-color:transparent\">5.2 resizeEvent&#xff1a;\u5904\u7406\u7a97\u53e3\u5927\u5c0f\u53d8\u5316<\/h5>\n<p>\u7a97\u53e3\u88ab\u62d6\u5927\u3001\u62d6\u5c0f&#xff0c;\u5c3a\u5bf8\u4e00\u53d8&#xff0c;\u8fd9\u4e2a\u4e8b\u4ef6\u7acb\u9a6c\u89e6\u53d1\u3002<\/p>\n<p>\/\/ \u51fd\u6570\u539f\u578b<br \/>\n[virtual protected] void QWidget::resizeEvent(QResizeEvent *event); <\/p>\n<p>\u5b9e\u73b0\u4ee3\u7801&#xff1a;<\/p>\n<p>#include &lt;QResizeEvent&gt;<\/p>\n<p>void Widget::resizeEvent(QResizeEvent *event)<br \/>\n{<br \/>\n    qDebug() &lt;&lt; &#034;\u7a97\u53e3\u65e7\u5c3a\u5bf8&#xff1a;&#034; &lt;&lt; event-&gt;oldSize();<br \/>\n    qDebug() &lt;&lt; &#034;\u7a97\u53e3\u65b0\u5c3a\u5bf8&#xff1a;&#034; &lt;&lt; event-&gt;size();<br \/>\n    qDebug() &lt;&lt; &#034;\u65b0\u5bbd\u5ea6&#xff1a;&#034; &lt;&lt; event-&gt;size().width();<br \/>\n    qDebug() &lt;&lt; &#034;\u65b0\u9ad8\u5ea6&#xff1a;&#034; &lt;&lt; event-&gt;size().height();<br \/>\n} <\/p>\n<p>event-&gt;oldSize()\u8bb0\u4e0b\u6539\u53d8\u524d\u7684\u5c3a\u5bf8&#xff0c;event-&gt;size()\u7ed9\u51fa\u6539\u53d8\u540e\u7684\u65b0\u5c3a\u5bf8\u3002\u60f3\u5355\u72ec\u62ff\u5bbd\u5ea6\u548c\u9ad8\u5ea6\u7684&#xff0c;\u518d\u8c03.width()\u548c.height()\u5c31\u884c\u3002\u4e00\u65e7\u4e00\u65b0&#xff0c;\u7a97\u53e3\u662f\u600e\u4e48\u88ab\u62c9\u957f\u3001\u538b\u6241\u7684&#xff0c;\u5168\u5728\u8fd9\u51e0\u884c\u91cc\u4e86\u3002<\/p>\n<h4 id=\"%E5%85%AD%E3%80%81%E4%BA%8B%E4%BB%B6%E5%88%86%E5%8F%91%E5%99%A8%E7%AE%80%E4%BB%8B\">\u516d\u3001\u4e8b\u4ef6\u5206\u53d1\u5668\u2014\u2014Qt\u5982\u4f55\u628a\u4e8b\u4ef6\u4ea4\u7ed9\u5bf9\u8c61<\/h4>\n<h5 id=\"6.1%20%E4%BA%8B%E4%BB%B6%E5%88%86%E5%8F%91%E5%99%A8%E7%9A%84%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86\">6.1 \u4e8b\u4ef6\u5206\u53d1\u5668\u7684\u57fa\u672c\u5de5\u4f5c\u539f\u7406<\/h5>\n<p>Qt\u91cc\u6240\u6709\u4e8b\u4ef6&#xff0c;\u4e0d\u7528\u7ba1\u4ece\u54ea\u6765&#xff0c;\u7b2c\u4e00\u7ad9\u90fd\u662fQObject::event()\u51fd\u6570\u3002\u5b83\u5c31\u662f\u4e8b\u4ef6\u5206\u53d1\u7684\u603b\u5165\u53e3&#xff0c;\u6240\u6709\u4e8b\u4ef6\u90fd\u5f97\u5148\u5230\u8fd9\u513f\u62a5\u5230\u3002\u4f46event()\u672c\u8eab\u4e0d\u5e72\u6d3b\u3002\u5b83\u4e0d\u76f4\u63a5\u5904\u7406\u4e8b\u4ef6&#xff0c;\u800c\u662f\u5148\u770b\u4e00\u773c\u4e8b\u4ef6\u7684\u7c7b\u578b&#xff0c;\u4e5f\u5c31\u662fevent-&gt;type()\u8fd4\u56de\u7684\u90a3\u4e2a\u503c&#xff0c;\u7136\u540e\u7167\u7740\u7c7b\u578b&#xff0c;\u628a\u4e8b\u4ef6\u8f6c\u624b\u4ea4\u7ed9\u5bf9\u5e94\u7684\u5177\u4f53\u5904\u7406\u51fd\u6570\u3002\u9f20\u6807\u4e8b\u4ef6\u7ed9mousePressEvent()&#xff0c;\u952e\u76d8\u4e8b\u4ef6\u7ed9keyPressEvent()&#xff0c;\u5404\u56de\u5404\u5bb6&#xff0c;\u5404\u627e\u5404\u5988\u3002<\/p>\n<p>\u6240\u4ee5&#xff0c;event()\u7684\u89d2\u8272\u66f4\u50cf\u4e00\u4e2a\u8c03\u5ea6\u53f0&#xff1a;\u6765\u4ec0\u4e48\u4ef6&#xff0c;\u5206\u4ec0\u4e48\u7a97\u53e3\u3002\u5b83\u53ea\u8d1f\u8d23\u5224\u65ad\u548c\u8f6c\u53d1&#xff0c;\u771f\u6b63\u7684\u5904\u7406\u903b\u8f91&#xff0c;\u8fd8\u662f\u843d\u5728\u90a3\u4e9b\u5177\u4f53\u7684xxxEvent()\u51fd\u6570\u8eab\u4e0a\u3002<\/p>\n<h5 id=\"6.2%20event()%E5%87%BD%E6%95%B0%E7%9A%84%E4%BD%9C%E7%94%A8\">6.2 event()\u51fd\u6570\u2014\u2014\u7edf\u4e00\u5904\u7406\u4e8b\u4ef6\u7684\u5165\u53e3<\/h5>\n<p>event()\u662f\u4e8b\u4ef6\u5206\u53d1\u7684\u603b\u5165\u53e3&#xff0c;\u5e73\u65f6\u5b83\u53ea\u662f\u6309\u90e8\u5c31\u73ed\u5730\u5224\u65ad\u7c7b\u578b\u3001\u8f6c\u624b\u5206\u53d1\u3002\u4f46\u4f60\u53ef\u4ee5\u628a\u8fd9\u4e2a\u5165\u53e3\u91cd\u5199\u6389&#xff0c;\u5728\u534a\u9053\u4e0a\u8bbe\u4e00\u9053\u5173\u5361&#xff0c;\u628a\u7ecf\u8fc7\u7684\u4e8b\u4ef6\u5148\u62e6\u4e0b\u6765\u5ba1\u4e00\u904d&#xff0c;\u5b9e\u73b0\u5168\u5c40\u7684\u4e8b\u4ef6\u5904\u7406\u6216\u8fc7\u6ee4\u3002<\/p>\n<p>bool Widget::event(QEvent *event)<br \/>\n{<br \/>\n    \/\/ \u62e6\u622a\u6240\u6709\u9f20\u6807\u6309\u4e0b\u4e8b\u4ef6<br \/>\n    if (event-&gt;type() &#061;&#061; QEvent::MouseButtonPress) {<br \/>\n        qDebug() &lt;&lt; &#034;\u62e6\u622a\u5230\u9f20\u6807\u6309\u4e0b\u4e8b\u4ef6&#034;;<br \/>\n        \/\/ \u8fd4\u56de true&#xff0c;\u8868\u793a\u4e8b\u4ef6\u5df2\u5904\u7406&#xff0c;\u4e0d\u518d\u5f80\u4e0b\u5206\u53d1<br \/>\n        return true;<br \/>\n    }<\/p>\n<p>    \/\/ \u5176\u4ed6\u4e8b\u4ef6&#xff0c;\u4ea4\u7ed9\u7236\u7c7b\u7ee7\u7eed\u5904\u7406<br \/>\n    return QWidget::event(event);<br \/>\n} <\/p>\n<p>\u8fd9\u91cc\u7684\u5173\u952e\u5728\u4e8e\u8fd4\u56de\u503c&#xff1a;\u8fd4\u56detrue&#xff0c;\u5c31\u7b49\u4e8e\u544a\u8bc9Qt\u201c\u8fd9\u4e8b\u513f\u6211\u5904\u7406\u4e86\u201d&#xff0c;\u4e8b\u4ef6\u5230\u6b64\u4e3a\u6b62&#xff0c;\u4e0d\u518d\u5f80\u4e0b\u8d70&#xff1b;\u8fd4\u56defalse\u6216\u8005\u8c03\u7528\u7236\u7c7b\u7684event()&#xff0c;\u4e8b\u4ef6\u624d\u4f1a\u7ee7\u7eed\u5206\u53d1\u3002<\/p>\n<p>\u91cd\u5199event()\u76f8\u5f53\u4e8e\u62ff\u4e86\u4e00\u5f20\u5168\u5c40\u62e6\u622a\u7684\u901a\u884c\u8bc1\u3002\u6240\u6709\u4e8b\u4ef6\u5728\u9001\u5f80\u5177\u4f53\u5904\u7406\u51fd\u6570\u4e4b\u524d&#xff0c;\u90fd\u5f97\u5148\u8fc7\u4f60\u8fd9\u9053\u5173\u3002\u60f3\u505a\u5168\u5c40\u5feb\u6377\u952e\u3001\u7edf\u4e00\u65e5\u5fd7\u3001\u7279\u6b8a\u4e8b\u4ef6\u5c4f\u853d&#xff0c;\u8fd9\u91cc\u662f\u6700\u5408\u9002\u7684\u4e0b\u624b\u70b9\u3002<\/p>\n<h4 id=\"%E5%85%A8%E6%96%87%E6%80%BB%E7%BB%93\" style=\"background-color:transparent\">\u4e03\u3001\u4e8b\u4ef6\u673a\u5236\u603b\u7ed3<\/h4>\n<p>\u672c\u6587\u628aQt\u4e8b\u4ef6\u673a\u5236\u7684\u5b8c\u6574\u77e5\u8bc6\u4f53\u7cfb\u7cfb\u7edf\u68b3\u7406\u4e86\u4e00\u904d&#xff0c;\u6838\u5fc3\u8981\u70b9\u6574\u7406\u5982\u4e0b&#xff1a;<\/p>\n<p>\u672c\u8d28\u5173\u7cfb&#xff1a;\u4fe1\u53f7\u69fd\u662f\u4e8b\u4ef6\u7684\u4e0a\u5c42\u5c01\u88c5&#xff0c;\u4e8b\u4ef6\u662f\u4fe1\u53f7\u69fd\u7684\u5e95\u5c42\u652f\u6491\u3002\u5e38\u89c4\u573a\u666f\u7528\u4fe1\u53f7\u69fd&#xff0c;\u81ea\u5b9a\u4e49\u573a\u666f\u7528\u4e8b\u4ef6\u3002<\/p>\n<p>\u6838\u5fc3\u5904\u7406\u65b9\u5f0f&#xff1a;\u7ee7\u627f\u6807\u51c6\u63a7\u4ef6\u7c7b&#xff0c;\u91cd\u5199\u5bf9\u5e94\u7684\u865a\u4e8b\u4ef6\u5904\u7406\u51fd\u6570&#xff0c;\u518d\u628a UI \u63a7\u4ef6\u63d0\u5347\u4e3a\u81ea\u5b9a\u4e49\u7c7b\u7684\u5b9e\u4f8b\u3002<\/p>\n<p>\u9f20\u6807\u4e8b\u4ef6&#xff1a;<\/p>\n<ul>\n<li>\u8fdb\u5165\u79bb\u5f00&#xff1a;enterEvent() \/ leaveEvent()<\/li>\n<li>\u70b9\u51fb\u91ca\u653e&#xff1a;mousePressEvent() \/ mouseReleaseEvent()&#xff0c;\u80fd\u62ff\u5230\u5c40\u90e8\/\u5168\u5c40\u5750\u6807\u548c\u6309\u952e\u7c7b\u578b<\/li>\n<li>\u79fb\u52a8\u4e8b\u4ef6&#xff1a;\u9ed8\u8ba4\u4e0d\u8ffd\u8e2a&#xff0c;\u60f3\u8ffd\u8e2a\u5f97\u624b\u52a8\u8c03 setMouseTracking(true)<\/li>\n<li>\u6eda\u8f6e\u4e8b\u4ef6&#xff1a;wheelEvent()&#xff0c;\u7528 delta() \u62ff\u6eda\u52a8\u8ddd\u79bb<\/li>\n<li>\u952e\u76d8\u4e8b\u4ef6&#xff1a;keyPressEvent() \/ keyReleaseEvent()&#xff0c;\u9760 key() \u5224\u65ad\u5355\u4e2a\u6309\u952e&#xff0c;\u9760 modifiers() \u5224\u65ad\u7ec4\u5408\u952e\u3002<\/li>\n<\/ul>\n<p>\u5b9a\u65f6\u5668\u4e8b\u4ef6&#xff1a;<\/p>\n<ul>\n<li>\u9ad8\u5c42\u63a5\u53e3 QTimer&#xff08;\u63a8\u8350&#xff09;&#xff0c;\u5e95\u5c42\u4e8b\u4ef6 QTimerEvent<\/li>\n<li>QTimerEvent \u5f97\u81ea\u5df1\u7ba1\u5b9a\u65f6\u5668 ID&#xff0c;\u5728 timerEvent() \u91cc\u533a\u5206\u4e0d\u540c\u5b9a\u65f6\u5668<\/li>\n<\/ul>\n<p>\u7a97\u53e3\u4e8b\u4ef6&#xff1a;moveEvent() \u6355\u83b7\u4f4d\u7f6e\u53d8\u5316&#xff0c;resizeEvent() \u6355\u83b7\u5927\u5c0f\u53d8\u5316\u3002<\/p>\n<p>\u4e8b\u4ef6\u5206\u53d1\u5668&#xff1a;\u6240\u6709\u4e8b\u4ef6\u90fd\u8981\u7ecf\u8fc7 event() \u51fd\u6570\u5206\u53d1\u3002\u53ef\u4ee5\u91cd\u5199\u5b83\u6765\u62e6\u622a\u4e8b\u4ef6&#xff0c;\u4f46\u7528\u7684\u65f6\u5019\u5f97\u60a0\u7740\u70b9\u3002<\/p>\n<p>\u5b9e\u9645\u5f00\u53d1\u4e2d&#xff0c;\u9075\u5faa\u4e00\u6761\u539f\u5219\u5c31\u597d&#xff1a;\u4f18\u5148\u7528\u4fe1\u53f7\u69fd&#xff0c;\u5fc5\u8981\u65f6\u4e0a\u4e8b\u4ef6\u3002 \u5728\u4fdd\u8bc1\u4ee3\u7801\u7b80\u6d01\u7684\u540c\u65f6&#xff0c;\u628a\u60f3\u8981\u7684\u6548\u679c\u505a\u51fa\u6765\u3002\u638c\u63e1\u4e8b\u4ef6\u673a\u5236&#xff0c;\u662f\u6df1\u5165Qt\u5f00\u53d1\u7684\u5fc5\u7ecf\u4e4b\u8def&#xff0c;\u5b83\u8ba9\u4f60\u771f\u6b63\u7406\u89e3GUI\u7a0b\u5e8f\u7684\u4ea4\u4e92\u672c\u8d28&#xff0c;\u4e5f\u8ba9\u4f60\u6709\u80fd\u529b\u5b9e\u73b0\u66f4\u7075\u6d3b\u3001\u66f4\u5f3a\u5927\u7684\u81ea\u5b9a\u4e49\u63a7\u4ef6\u548c\u4ea4\u4e92\u6548\u679c\u3002<\/p>\n<hr \/>\n<h4 id=\"%E7%BB%93%E5%B0%BE\">\u7ed3\u5c3e<\/h4>\n<p>\u5230\u8fd9\u91cc&#xff0c;Qt\u4e8b\u4ef6\u673a\u5236\u7684\u6838\u5fc3\u5185\u5bb9\u5c31\u5168\u90e8\u8bb2\u5b8c\u4e86\u3002\u4ece\u9f20\u6807\u3001\u952e\u76d8\u5230\u5b9a\u65f6\u5668\u3001\u7a97\u53e3&#xff0c;\u518d\u5230\u4e8b\u4ef6\u5206\u53d1\u5668&#xff0c;\u8fd9\u4e00\u8def\u8d70\u4e0b\u6765&#xff0c;\u4f60\u4f1a\u53d1\u73b0&#xff0c;GUI\u7a0b\u5e8f\u7684\u6bcf\u4e00\u6b21\u201c\u56de\u5e94\u201d&#xff0c;\u80cc\u540e\u90fd\u662f\u4e8b\u4ef6\u5728\u9a71\u52a8\u3002\u4fe1\u53f7\u69fd\u8ba9\u5f00\u53d1\u53d8\u7b80\u5355&#xff0c;\u4e8b\u4ef6\u673a\u5236\u5219\u8ba9\u5b9a\u5236\u53d8\u81ea\u7531\u3002\u771f\u6b63\u7406\u89e3\u4e8b\u4ef6&#xff0c;\u624d\u7b97\u6478\u5230\u4e86Qt\u4ea4\u4e92\u7684\u5e95\u5c42\u8109\u640f\u3002<\/p>\n<p>\u63a5\u4e0b\u6765&#xff0c;\u628a\u8fd9\u4e9b\u4ee3\u7801\u8dd1\u4e00\u8dd1\u3001\u6539\u4e00\u6539&#xff0c;\u8bd5\u7740\u7ed9\u81ea\u5df1\u7684\u63a7\u4ef6\u52a0\u4e0a\u60ac\u505c\u52a8\u753b\u3001\u5168\u5c40\u5feb\u6377\u952e\u6216\u8005\u62d6\u62fd\u7ed8\u5236\u3002\u4f60\u4f1a\u53d1\u73b0&#xff0c;\u4e8b\u4ef6\u673a\u5236\u8fdc\u6bd4\u60f3\u8c61\u4e2d\u5f3a\u5927\u3002\u5f88\u591a\u770b\u4f3c\u590d\u6742\u7684\u4ea4\u4e92\u6548\u679c&#xff0c;\u62c6\u5f00\u770b&#xff0c;\u4e0d\u8fc7\u662f\u51e0\u4e2a\u4e8b\u4ef6\u51fd\u6570\u7684\u7ec4\u5408\u800c\u5df2\u3002<\/p>\n<p>\u611f\u8c22\u9605\u8bfb\u3002\u5982\u679c\u672c\u6587\u5bf9\u4f60\u6709\u5e2e\u52a9&#xff0c;\u522b\u5fd8\u4e86\u70b9\u8d5e\u3001\u6536\u85cf\u3001\u5173\u6ce8\u4e09\u8fde\u652f\u6301\u3002\u4f60\u7684\u6bcf\u4e00\u6b21\u53cd\u9988&#xff0c;\u90fd\u662f\u6211\u7ee7\u7eed\u786c\u6838\u8f93\u51fa\u7684\u6700\u5927\u52a8\u529b\u3002\u6211\u4eec\u4e0b\u7bc7\u89c1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Qt\u4f5c\u4e3a\u4e3b\u6d41GUI\u5f00\u53d1\u6846\u67b6&#xff0c;\u5176\u6838\u5fc3\u4ea4\u4e92\u80fd\u529b&#xff0c;\u5168\u90fd\u67b6\u5728\u4e8b\u4ef6\u673a\u5236\u8fd9\u6839\u9aa8\u5934\u4e0a\u3002\u4f60\u5e73\u65f6\u70b9\u7684\u6309\u94ae\u3001\u6572\u7684\u6587\u672c\u3001\u62d6\u7684\u7a97\u53e3&#xff0c;\u80cc\u540e\u65e0\u4e00\u4f8b\u5916&#xff0c;\u90fd\u662f\u64cd\u4f5c\u7cfb\u7edf\u5148\u4ea7\u751f\u4e8b\u4ef6&#xff0c;\u518d\u7531Qt\u5c01\u88c5\u597d&#xff0c;\u9012\u5230\u5e94\u7528\u7a0b\u5e8f\u624b\u91cc\u3002\u7edd\u5927\u591a\u6570\u573a\u666f\u4e0b&#xff0c;\u4fe1\u53f7\u69fd\u8db3\u591f\u597d\u7528&#xff0c;\u70b9\u4e00\u4e0b\u3001\u54cd\u4e00\u4e0b&#xff0c;\u8f7b\u677e\u641e\u5b9a\u3002\u53ef\u4e00\u65e6\u8981\u505a\u9ad8\u5ea6\u81ea\u5b9a\u4e49\u7684\u4ea4\u4e92&#xff0c;\u6bd4\u5982\u7ed9\u6309\u94ae\u52a0\u60ac\u505c\u52a8\u753b\u3001\u5168\u5c40\u62e6\u622a\u952e\u76d8\u5feb\u6377\u952e\u3001\u9f20\u6807\u62d6\u62fd\u753b\u56fe\u3001\u7cbe\u51c6\u63a7\u5236\u5b9a\u65f6\u5668&amp;#<\/p>\n","protected":false},"author":2,"featured_media":110104,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10580,55,218,780,1666],"topic":[],"class_list":["post-110105","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-qt5","tag-c","tag-qt","tag-ui","tag-1666"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u300aQt\u4ece\u96f6\u5165\u95e8\u7cfb\u5217\uff08\u5341\u4e00\uff09\uff1aQt\u4e8b\u4ef6\u673a\u5236\u8be6\u89e3\u2014\u2014\u4eceQEvent\u5230\u9f20\u6807\u3001\u952e\u76d8\u4e0e\u5b9a\u65f6\u5668\u4e8b\u4ef6\u300b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/110105.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u300aQt\u4ece\u96f6\u5165\u95e8\u7cfb\u5217\uff08\u5341\u4e00\uff09\uff1aQt\u4e8b\u4ef6\u673a\u5236\u8be6\u89e3\u2014\u2014\u4eceQEvent\u5230\u9f20\u6807\u3001\u952e\u76d8\u4e0e\u5b9a\u65f6\u5668\u4e8b\u4ef6\u300b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Qt\u4f5c\u4e3a\u4e3b\u6d41GUI\u5f00\u53d1\u6846\u67b6&#xff0c;\u5176\u6838\u5fc3\u4ea4\u4e92\u80fd\u529b&#xff0c;\u5168\u90fd\u67b6\u5728\u4e8b\u4ef6\u673a\u5236\u8fd9\u6839\u9aa8\u5934\u4e0a\u3002\u4f60\u5e73\u65f6\u70b9\u7684\u6309\u94ae\u3001\u6572\u7684\u6587\u672c\u3001\u62d6\u7684\u7a97\u53e3&#xff0c;\u80cc\u540e\u65e0\u4e00\u4f8b\u5916&#xff0c;\u90fd\u662f\u64cd\u4f5c\u7cfb\u7edf\u5148\u4ea7\u751f\u4e8b\u4ef6&#xff0c;\u518d\u7531Qt\u5c01\u88c5\u597d&#xff0c;\u9012\u5230\u5e94\u7528\u7a0b\u5e8f\u624b\u91cc\u3002\u7edd\u5927\u591a\u6570\u573a\u666f\u4e0b&#xff0c;\u4fe1\u53f7\u69fd\u8db3\u591f\u597d\u7528&#xff0c;\u70b9\u4e00\u4e0b\u3001\u54cd\u4e00\u4e0b&#xff0c;\u8f7b\u677e\u641e\u5b9a\u3002\u53ef\u4e00\u65e6\u8981\u505a\u9ad8\u5ea6\u81ea\u5b9a\u4e49\u7684\u4ea4\u4e92&#xff0c;\u6bd4\u5982\u7ed9\u6309\u94ae\u52a0\u60ac\u505c\u52a8\u753b\u3001\u5168\u5c40\u62e6\u622a\u952e\u76d8\u5feb\u6377\u952e\u3001\u9f20\u6807\u62d6\u62fd\u753b\u56fe\u3001\u7cbe\u51c6\u63a7\u5236\u5b9a\u65f6\u5668&amp;#\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/110105.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-25T15:09:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260925150920-6ab68ea0979ff.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/110105.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/110105.html\",\"name\":\"\u300aQt\u4ece\u96f6\u5165\u95e8\u7cfb\u5217\uff08\u5341\u4e00\uff09\uff1aQt\u4e8b\u4ef6\u673a\u5236\u8be6\u89e3\u2014\u2014\u4eceQEvent\u5230\u9f20\u6807\u3001\u952e\u76d8\u4e0e\u5b9a\u65f6\u5668\u4e8b\u4ef6\u300b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-25T15:09:21+00:00\",\"dateModified\":\"2026-09-25T15:09:21+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/110105.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/110105.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/110105.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u300aQt\u4ece\u96f6\u5165\u95e8\u7cfb\u5217\uff08\u5341\u4e00\uff09\uff1aQt\u4e8b\u4ef6\u673a\u5236\u8be6\u89e3\u2014\u2014\u4eceQEvent\u5230\u9f20\u6807\u3001\u952e\u76d8\u4e0e\u5b9a\u65f6\u5668\u4e8b\u4ef6\u300b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u300aQt\u4ece\u96f6\u5165\u95e8\u7cfb\u5217\uff08\u5341\u4e00\uff09\uff1aQt\u4e8b\u4ef6\u673a\u5236\u8be6\u89e3\u2014\u2014\u4eceQEvent\u5230\u9f20\u6807\u3001\u952e\u76d8\u4e0e\u5b9a\u65f6\u5668\u4e8b\u4ef6\u300b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/110105.html","og_locale":"zh_CN","og_type":"article","og_title":"\u300aQt\u4ece\u96f6\u5165\u95e8\u7cfb\u5217\uff08\u5341\u4e00\uff09\uff1aQt\u4e8b\u4ef6\u673a\u5236\u8be6\u89e3\u2014\u2014\u4eceQEvent\u5230\u9f20\u6807\u3001\u952e\u76d8\u4e0e\u5b9a\u65f6\u5668\u4e8b\u4ef6\u300b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Qt\u4f5c\u4e3a\u4e3b\u6d41GUI\u5f00\u53d1\u6846\u67b6&#xff0c;\u5176\u6838\u5fc3\u4ea4\u4e92\u80fd\u529b&#xff0c;\u5168\u90fd\u67b6\u5728\u4e8b\u4ef6\u673a\u5236\u8fd9\u6839\u9aa8\u5934\u4e0a\u3002\u4f60\u5e73\u65f6\u70b9\u7684\u6309\u94ae\u3001\u6572\u7684\u6587\u672c\u3001\u62d6\u7684\u7a97\u53e3&#xff0c;\u80cc\u540e\u65e0\u4e00\u4f8b\u5916&#xff0c;\u90fd\u662f\u64cd\u4f5c\u7cfb\u7edf\u5148\u4ea7\u751f\u4e8b\u4ef6&#xff0c;\u518d\u7531Qt\u5c01\u88c5\u597d&#xff0c;\u9012\u5230\u5e94\u7528\u7a0b\u5e8f\u624b\u91cc\u3002\u7edd\u5927\u591a\u6570\u573a\u666f\u4e0b&#xff0c;\u4fe1\u53f7\u69fd\u8db3\u591f\u597d\u7528&#xff0c;\u70b9\u4e00\u4e0b\u3001\u54cd\u4e00\u4e0b&#xff0c;\u8f7b\u677e\u641e\u5b9a\u3002\u53ef\u4e00\u65e6\u8981\u505a\u9ad8\u5ea6\u81ea\u5b9a\u4e49\u7684\u4ea4\u4e92&#xff0c;\u6bd4\u5982\u7ed9\u6309\u94ae\u52a0\u60ac\u505c\u52a8\u753b\u3001\u5168\u5c40\u62e6\u622a\u952e\u76d8\u5feb\u6377\u952e\u3001\u9f20\u6807\u62d6\u62fd\u753b\u56fe\u3001\u7cbe\u51c6\u63a7\u5236\u5b9a\u65f6\u5668&amp;#","og_url":"https:\/\/www.wsisp.com\/helps\/110105.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-25T15:09:21+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260925150920-6ab68ea0979ff.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/110105.html","url":"https:\/\/www.wsisp.com\/helps\/110105.html","name":"\u300aQt\u4ece\u96f6\u5165\u95e8\u7cfb\u5217\uff08\u5341\u4e00\uff09\uff1aQt\u4e8b\u4ef6\u673a\u5236\u8be6\u89e3\u2014\u2014\u4eceQEvent\u5230\u9f20\u6807\u3001\u952e\u76d8\u4e0e\u5b9a\u65f6\u5668\u4e8b\u4ef6\u300b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-25T15:09:21+00:00","dateModified":"2026-09-25T15:09:21+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/110105.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/110105.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/110105.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u300aQt\u4ece\u96f6\u5165\u95e8\u7cfb\u5217\uff08\u5341\u4e00\uff09\uff1aQt\u4e8b\u4ef6\u673a\u5236\u8be6\u89e3\u2014\u2014\u4eceQEvent\u5230\u9f20\u6807\u3001\u952e\u76d8\u4e0e\u5b9a\u65f6\u5668\u4e8b\u4ef6\u300b"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/110105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=110105"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/110105\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/110104"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=110105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=110105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=110105"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=110105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}