{"id":119294,"date":"2026-10-29T09:17:55","date_gmt":"2026-10-29T01:17:55","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/119294.html"},"modified":"2026-10-29T09:17:55","modified_gmt":"2026-10-29T01:17:55","slug":"qt%e5%b8%b8%e7%94%a8%e6%8e%a7%e4%bb%b6%ef%bc%9aqwidget%e5%b8%b8%e7%94%a8%e5%b1%9e%e6%80%a7%ef%bc%8c%e6%8e%a7%e4%bb%b6%e4%bd%bf%e8%83%bd%e3%80%81%e4%bd%8d%e7%bd%ae%e5%b0%ba%e5%af%b8%e3%80%81%e9%a1%b6","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/119294.html","title":{"rendered":"Qt\u5e38\u7528\u63a7\u4ef6\uff1aQWidget\u5e38\u7528\u5c5e\u6027\uff0c\u63a7\u4ef6\u4f7f\u80fd\u3001\u4f4d\u7f6e\u5c3a\u5bf8\u3001\u9876\u5c42\u7a97\u53e3\u6807\u9898\/\u56fe\u6807\u3001\u900f\u660e\u5ea6\u3001\u9f20\u6807\u3001\u5b57\u4f53\u3001\u9f20\u6807\u60ac\u505c\u63d0\u793a\u3001\u7126\u70b9\u3001widget\u6837\u5f0f\uff08\u53d6\u8272\u5668\u7b49\uff09"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"-toc\" style=\"margin-left:0px\">\n<p id=\"1.%20%E6%8E%A7%E4%BB%B6%E6%A6%82%E8%BF%B0-toc\" style=\"margin-left:0px\">1. \u63a7\u4ef6\u6982\u8ff0<\/p>\n<p id=\"2.%20QWidget%20%E6%A0%B8%E5%BF%83%E5%B1%9E%E6%80%A7-toc\" style=\"margin-left:0px\">2. QWidget \u6838\u5fc3\u5c5e\u6027<\/p>\n<p id=\"2.1%20QWidget%20%E5%B8%B8%E7%94%A8%E5%B1%9E%E6%80%A7%E4%B8%80%E8%A7%88-toc\" style=\"margin-left:40px\">2.1 QWidget \u5e38\u7528\u5c5e\u6027\u4e00\u89c8<\/p>\n<p id=\"2.2%20enabled%EF%BC%88%E6%8E%A7%E4%BB%B6%E4%BD%BF%E8%83%BD%EF%BC%89-toc\" style=\"margin-left:40px\">2.2 enabled&#xff08;\u63a7\u4ef6\u4f7f\u80fd&#xff09;<\/p>\n<p id=\"2.3%20geometry%EF%BC%88%E4%BD%8D%E7%BD%AE%2F%E5%B0%BA%E5%AF%B8%EF%BC%89-toc\" style=\"margin-left:40px\">2.3 geometry&#xff08;\u4f4d\u7f6e\/\u5c3a\u5bf8&#xff09;<\/p>\n<p id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E6%8E%A7%E5%88%B6%E6%8C%89%E9%92%AE%E7%9A%84%E4%BD%8D%E7%BD%AE-toc\" style=\"margin-left:80px\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u63a7\u5236\u6309\u94ae\u7684\u4f4d\u7f6e<\/p>\n<p id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E4%B8%80%E4%B8%AA%E8%A1%A8%E7%99%BD%E7%A8%8B%E5%BA%8F-toc\" style=\"margin-left:80px\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u4e00\u4e2a\u8868\u767d\u7a0b\u5e8f<\/p>\n<p id=\"window%20frame%20%E7%9A%84%E5%BD%B1%E5%93%8D-toc\" style=\"margin-left:80px\">window frame \u7684\u5f71\u54cd<\/p>\n<p id=\"2.4%20windowTitle%EF%BC%88%E9%A1%B6%E5%B1%82%E7%AA%97%E5%8F%A3%E6%A0%87%E9%A2%98%EF%BC%89-toc\" style=\"margin-left:40px\">2.4 windowTitle&#xff08;\u9876\u5c42\u7a97\u53e3\u6807\u9898&#xff09;<\/p>\n<p id=\"2.5%20windowIcon%EF%BC%88%E9%A1%B6%E5%B1%82%E7%AA%97%E5%8F%A3%E5%9B%BE%E6%A0%87%EF%BC%89-toc\" style=\"margin-left:40px\">2.5 windowIcon&#xff08;\u9876\u5c42\u7a97\u53e3\u56fe\u6807&#xff09;<\/p>\n<p id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E8%AE%BE%E7%BD%AE%E7%AA%97%E5%8F%A3%E5%9B%BE%E6%A0%87-toc\" style=\"margin-left:80px\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u8bbe\u7f6e\u7a97\u53e3\u56fe\u6807<\/p>\n<p id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E8%8E%B7%E5%8F%96%E5%BD%93%E5%89%8D%E7%9A%84%E5%B7%A5%E4%BD%9C%E7%9B%AE%E5%BD%95-toc\" style=\"margin-left:80px\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u83b7\u53d6\u5f53\u524d\u7684\u5de5\u4f5c\u76ee\u5f55<\/p>\n<p id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E9%80%9A%E8%BF%87%20qrc%20%E7%AE%A1%E7%90%86%E5%9B%BE%E7%89%87%E4%BD%9C%E4%B8%BA%E5%9B%BE%E6%A0%87-toc\" style=\"margin-left:80px\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u901a\u8fc7 qrc \u7ba1\u7406\u56fe\u7247\u4f5c\u4e3a\u56fe\u6807<\/p>\n<p id=\"2.6%20windowOpacity%EF%BC%88%E6%8E%A7%E4%BB%B6%E9%80%8F%E6%98%8E%E5%BA%A6%EF%BC%89-toc\" style=\"margin-left:40px\">2.6 windowOpacity&#xff08;\u63a7\u4ef6\u900f\u660e\u5ea6&#xff09;<\/p>\n<p id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E8%B0%83%E6%95%B4%E7%AA%97%E5%8F%A3%E9%80%8F%E6%98%8E%E5%BA%A6-toc\" style=\"margin-left:80px\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u8c03\u6574\u7a97\u53e3\u900f\u660e\u5ea6<\/p>\n<p id=\"2.7%20cursor%EF%BC%88%E9%BC%A0%E6%A0%87%EF%BC%89-toc\" style=\"margin-left:40px\">2.7 cursor&#xff08;\u9f20\u6807&#xff09;<\/p>\n<p id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E5%9C%A8%20Qt%20Designer%20%E4%B8%AD%E8%AE%BE%E7%BD%AE%E6%8C%89%E9%92%AE%E7%9A%84%E5%85%89%E6%A0%87-toc\" style=\"margin-left:80px\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u5728 Qt Designer \u4e2d\u8bbe\u7f6e\u6309\u94ae\u7684\u5149\u6807<\/p>\n<p id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E9%80%9A%E8%BF%87%E4%BB%A3%E7%A0%81%E8%AE%BE%E7%BD%AE%E6%8C%89%E9%92%AE%E7%9A%84%E5%85%89%E6%A0%87-toc\" style=\"margin-left:80px\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u901a\u8fc7\u4ee3\u7801\u8bbe\u7f6e\u6309\u94ae\u7684\u5149\u6807<\/p>\n<p id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E8%87%AA%E5%AE%9A%E4%B9%89%E9%BC%A0%E6%A0%87%E5%9B%BE%E6%A0%87-toc\" style=\"margin-left:80px\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u81ea\u5b9a\u4e49\u9f20\u6807\u56fe\u6807<\/p>\n<p id=\"2.8%20font%EF%BC%88%E5%AD%97%E4%BD%93%EF%BC%89-toc\" style=\"margin-left:40px\">2.8 font&#xff08;\u5b57\u4f53&#xff09;<\/p>\n<p id=\"%E7%A4%BA%E4%BE%8B%EF%BC%9A%E5%9C%A8%20Qt%20Designer%20%E4%B8%AD%E8%AE%BE%E7%BD%AE%E5%AD%97%E4%BD%93%E5%B1%9E%E6%80%A7-toc\" style=\"margin-left:80px\">\u793a\u4f8b&#xff1a;\u5728 Qt Designer \u4e2d\u8bbe\u7f6e\u5b57\u4f53\u5c5e\u6027<\/p>\n<p id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E5%9C%A8%E4%BB%A3%E7%A0%81%E4%B8%AD%E8%AE%BE%E7%BD%AE%E5%AD%97%E4%BD%93%E5%B1%9E%E6%80%A7%E3%80%82-toc\" style=\"margin-left:80px\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u5728\u4ee3\u7801\u4e2d\u8bbe\u7f6e\u5b57\u4f53\u5c5e\u6027\u3002<\/p>\n<p id=\"2.9%20toolTip%EF%BC%88%E9%BC%A0%E6%A0%87%E6%82%AC%E5%81%9C%E6%8F%90%E7%A4%BA%EF%BC%89-toc\" style=\"margin-left:40px\">2.9 toolTip&#xff08;\u9f20\u6807\u60ac\u505c\u63d0\u793a&#xff09;<\/p>\n<p id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E8%AE%BE%E7%BD%AE%E6%8C%89%E9%92%AE%E7%9A%84%20toolTip-toc\" style=\"margin-left:80px\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u8bbe\u7f6e\u6309\u94ae\u7684 toolTip<\/p>\n<p id=\"2.10%20focusPolicy%EF%BC%88%E7%84%A6%E7%82%B9%EF%BC%89-toc\" style=\"margin-left:40px\">2.10 focusPolicy&#xff08;\u7126\u70b9&#xff09;<\/p>\n<p id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E7%90%86%E8%A7%A3%E4%B8%8D%E5%90%8C%E7%9A%84%20focusPolicy-toc\" style=\"margin-left:80px\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u7406\u89e3\u4e0d\u540c\u7684 focusPolicy<\/p>\n<p id=\"2.11%20styleSheet%EF%BC%88widget%E6%A0%B7%E5%BC%8F%EF%BC%89-toc\" style=\"margin-left:40px\">2.11 styleSheet&#xff08;widget\u6837\u5f0f&#xff09;<\/p>\n<p id=\"%E7%A4%BA%E4%BE%8B%3A%20%E8%AE%BE%E7%BD%AE%E6%96%87%E6%9C%AC%E6%A0%B7%E5%BC%8F-toc\" style=\"margin-left:80px\">\u793a\u4f8b: \u8bbe\u7f6e\u6587\u672c\u6837\u5f0f<\/p>\n<p id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%3A%20%E5%AE%9E%E7%8E%B0%E5%88%87%E6%8D%A2%E5%A4%9C%E9%97%B4%E6%A8%A1%E5%BC%8F%E3%80%82-toc\" style=\"margin-left:80px\">\u4ee3\u7801\u793a\u4f8b: \u5b9e\u73b0\u5207\u6362\u591c\u95f4\u6a21\u5f0f\u3002<\/p>\n<p id=\"%E5%8F%96%E8%89%B2%E5%99%A8-toc\" style=\"margin-left:80px\">\u53d6\u8272\u5668<\/p>\n<hr id=\"hr-toc\" \/>\n<h2 id=\"1.%20%E6%8E%A7%E4%BB%B6%E6%A6%82%E8%BF%B0\" style=\"background-color:transparent\">1. \u63a7\u4ef6\u6982\u8ff0<\/h2>\n<p>Widget \u662f Qt \u4e2d\u7684\u6838\u5fc3\u6982\u5ff5\u3002\u82f1\u6587\u539f\u4e49\u662f\u201c\u5c0f\u90e8\u4ef6\u201d&#xff0c;\u6211\u4eec\u6b64\u5904\u4e5f\u628a\u5b83\u7ffb\u8bd1\u4e3a\u201c\u63a7\u4ef6\u201d\u3002\u63a7\u4ef6\u662f\u6784\u6210\u4e00\u4e2a\u56fe\u5f62\u5316\u754c\u9762\u7684\u57fa\u672c\u8981\u7d20\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1007\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011749-6ae29ebdddebb.png\" width=\"1801\" \/><\/p>\n<p>\u50cf\u4e0a\u8ff0\u793a\u4f8b\u4e2d\u7684&#xff0c;\u6309\u94ae&#xff0c;\u5217\u8868\u89c6\u56fe&#xff0c;\u6811\u5f62\u89c6\u56fe&#xff0c;\u5355\u884c\u8f93\u5165\u6846&#xff0c;\u591a\u884c\u8f93\u5165\u6846&#xff0c;\u6eda\u52a8\u6761&#xff0c;\u4e0b\u62c9\u6846\u7b49&#xff0c;\u90fd\u53ef\u4ee5\u79f0\u4e3a\u201c\u63a7\u4ef6\u201d\u3002<\/p>\n<p>Qt \u4f5c\u4e3a\u4e00\u4e2a\u6210\u719f\u7684 GUI \u5f00\u53d1\u6846\u67b6&#xff0c;\u5185\u7f6e\u4e86\u5927\u91cf\u7684\u5e38\u7528\u63a7\u4ef6\u3002\u8fd9\u4e00\u70b9\u5728 Qt Designer \u4e2d\u5c31\u53ef\u4ee5\u770b\u5230\u7aef\u502a\u3002\u5e76\u4e14 Qt \u4e5f\u63d0\u4f9b\u4e86\u201c\u81ea\u5b9a\u4e49\u63a7\u4ef6\u201d\u7684\u80fd\u529b&#xff0c;\u53ef\u4ee5\u8ba9\u7a0b\u5e8f\u733f\u5728\u73b0\u6709\u63a7\u4ef6\u4e0d\u80fd\u6ee1\u8db3\u9700\u6c42\u7684\u65f6\u5019&#xff0c;\u5bf9\u73b0\u6709\u63a7\u4ef6\u505a\u51fa\u6269\u5c55&#xff0c;\u6216\u8005\u624b\u6413\u51fa\u65b0\u7684\u63a7\u4ef6\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1190\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011751-6ae29ebf54ff1.png\" width=\"297\" \/><\/p>\n<h2 id=\"2.%20QWidget%20%E6%A0%B8%E5%BF%83%E5%B1%9E%E6%80%A7\" style=\"background-color:transparent\">2. QWidget \u6838\u5fc3\u5c5e\u6027<\/h2>\n<ul>\n<li>\u5728 Qt \u4e2d&#xff0c;\u4f7f\u7528 QWidget \u7c7b\u8868\u793a\u201c\u63a7\u4ef6\u201d\u3002\u50cf\u6309\u94ae&#xff0c;\u89c6\u56fe&#xff0c;\u8f93\u5165\u6846&#xff0c;\u6eda\u52a8\u6761\u7b49\u5177\u4f53\u7684\u63a7\u4ef6\u7c7b&#xff0c;\u90fd\u662f\u7ee7\u627f\u81ea QWidget\u3002<\/li>\n<li>\u53ef\u4ee5\u8bf4&#xff0c;QWidget \u4e2d\u5c31\u5305\u542b\u4e86 Qt \u6574\u4e2a\u63a7\u4ef6\u4f53\u7cfb\u4e2d&#xff0c;\u901a\u7528\u7684\u90e8\u5206\u3002<\/li>\n<li>\u5728 Qt Designer \u4e2d&#xff0c;\u968f\u4fbf\u62d6\u4e00\u4e2a\u63a7\u4ef6\u8fc7\u6765&#xff0c;\u9009\u4e2d\u8be5\u63a7\u4ef6&#xff0c;\u5373\u53ef\u5728\u53f3\u4e0b\u65b9\u770b\u5230 QWidget \u4e2d\u7684\u5c5e\u6027<\/li>\n<li>\u8fd9\u4e9b\u5c5e\u6027\u65e2\u53ef\u4ee5\u901a\u8fc7 QtDesigner \u76f4\u63a5\u4fee\u6539&#xff0c;\u4e5f\u53ef\u4ee5\u901a\u8fc7\u4ee3\u7801\u7684\u65b9\u5f0f\u4fee\u6539\u3002<\/li>\n<li>\u8fd9\u4e9b\u5c5e\u6027\u7684\u5177\u4f53\u542b\u4e49&#xff0c;\u5728 Qt Assistant \u4e2d\u5747\u6709\u8be6\u7ec6\u4ecb\u7ecd\u3002<\/li>\n<li>\u5728 Qt Assistant \u4e2d\u641c\u7d22 QWidget&#xff0c;\u5373\u53ef\u627e\u5230\u5bf9\u5e94\u7684\u6587\u6863\u8bf4\u660e\u3002&#xff08;<span style=\"color:#fe2c24\">\u6216\u8005\u5728 Qt Creator \u4ee3\u7801\u4e2d&#xff0c;\u9009\u4e2d QWidget&#xff0c;\u6309 F1 \u4e5f\u53ef<\/span>&#xff09;\u3002<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"667\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011751-6ae29ebf797a8.png\" width=\"1234\" \/><\/p>\n<h3 id=\"2.1%20QWidget%20%E5%B8%B8%E7%94%A8%E5%B1%9E%E6%80%A7%E4%B8%80%E8%A7%88\" style=\"background-color:transparent\">2.1 QWidget \u5e38\u7528\u5c5e\u6027\u4e00\u89c8<\/h3>\n<p>\u4e0b\u5217\u8868\u683c\u5217\u51fa\u4e86 QWidget \u4e2d\u7684\u5c5e\u6027\u53ca\u5176\u4f5c\u7528\u3002<\/p>\n<table>\n<tr>\u5c5e\u6027\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#fe2c24\">enabled<\/span><\/td>\n<td>\u8bbe\u7f6e\u63a7\u4ef6\u662f\u5426\u53ef\u4f7f\u7528\u3002true \u8868\u793a\u53ef\u7528&#xff0c;false \u8868\u793a\u7981\u7528\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">geometry<\/span><\/td>\n<td>\u4f4d\u7f6e\u548c\u5c3a\u5bf8\u3002\u5305\u542b x\u3001y\u3001width\u3001height \u56db\u4e2a\u90e8\u5206&#xff0c;\u5176\u4e2d\u5750\u6807\u662f\u4ee5\u7236\u5143\u7d20\u4e3a\u53c2\u8003\u8fdb\u884c\u8bbe\u7f6e\u7684\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">windowTitle<\/span><\/td>\n<td>\u8bbe\u7f6e widget \u6807\u9898\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">windowIcon<\/span><\/td>\n<td>\u8bbe\u7f6e widget \u56fe\u6807\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">windowOpacity<\/span><\/td>\n<td>\u8bbe\u7f6e widget \u900f\u660e\u5ea6\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">cursor<\/span><\/td>\n<td>\u9f20\u6807\u60ac\u505c\u65f6\u663e\u793a\u7684\u56fe\u6807\u5f62\u72b6&#xff0c;\u662f\u666e\u901a\u7bad\u5934&#xff0c;\u8fd8\u662f\u6c99\u6f0f&#xff0c;\u8fd8\u662f\u5341\u5b57\u7b49\u5f62\u72b6\u3002\u5728 Qt Designer \u754c\u9762\u4e2d\u53ef\u4ee5\u6e05\u695a\u770b\u5230\u53ef\u9009\u9879\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">font<\/span><\/td>\n<td>\u5b57\u4f53\u76f8\u5173\u5c5e\u6027\u3002\u6d89\u53ca\u5230\u5b57\u4f53\u5bb6\u65cf\u3001\u5b57\u4f53\u5927\u5c0f\u3001\u7c97\u4f53\u3001\u659c\u4f53\u3001\u4e0b\u5212\u7ebf\u7b49\u7b49\u6837\u5f0f\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">toolTip<\/span><\/td>\n<td>\u9f20\u6807\u60ac\u505c\u5728 widget \u4e0a\u4f1a\u5728\u72b6\u6001\u680f\u4e2d\u663e\u793a\u7684\u63d0\u793a\u4fe1\u606f\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">toolTipDuring<\/span><\/td>\n<td>toolTip \u663e\u793a\u7684\u6301\u7eed\u65f6\u95f4\u3002<\/td>\n<\/tr>\n<tr>\n<td>statusTip<\/td>\n<td>Widget \u72b6\u6001\u53d1\u751f\u6539\u53d8\u65f6\u663e\u793a\u7684\u63d0\u793a\u4fe1\u606f&#xff08;\u6bd4\u5982\u6309\u94ae\u88ab\u6309\u4e0b\u7b49&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td>whatsThis<\/td>\n<td>\u9f20\u6807\u60ac\u505c\u5e76\u6309\u4e0b alt&#043;F1 \u65f6&#xff0c;\u663e\u793a\u7684\u5e2e\u52a9\u4fe1\u606f&#xff08;\u663e\u793a\u5728\u4e00\u4e2a\u5f39\u51fa\u7684\u7a97\u53e3\u4e2d&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">styleSheet<\/span><\/td>\n<td>\u5141\u8bb8\u4f7f\u7528 CSS \u6765\u8bbe\u7f6e widget \u4e2d\u7684\u6837\u5f0f\u3002Qt \u4e2d\u652f\u6301\u7684\u6837\u5f0f\u975e\u5e38\u4e30\u5bcc&#xff0c;\u5bf9\u4e8e\u524d\u7aef\u5f00\u53d1\u4eba\u5458\u4e0a\u624b\u662f\u975e\u5e38\u53cb\u597d\u7684\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">focusPolicy<\/span><\/td>\n<td>\u8be5 widget \u5982\u4f55\u83b7\u53d6\u5230\u7126\u70b9\u3002 \u2022 Qt::NoFocus&#xff1a;\u63a7\u4ef6\u4e0d\u53c2\u4e0e\u7126\u70b9\u7ba1\u7406&#xff0c;\u5373\u65e0\u6cd5\u901a\u8fc7\u952e\u76d8\u6216\u9f20\u6807\u83b7\u53d6\u7126\u70b9 \u2022 Qt::TabFocus&#xff1a;\u63a7\u4ef6\u53ef\u4ee5\u901a\u8fc7 Tab \u952e\u83b7\u5f97\u7126\u70b9 \u2022 Qt::ClickFocus&#xff1a;\u63a7\u4ef6\u53ef\u4ee5\u901a\u8fc7\u9f20\u6807\u70b9\u51fb\u83b7\u5f97\u7126\u70b9 \u2022 Qt::StrongFocus&#xff1a;\u63a7\u4ef6\u53ef\u4ee5\u901a\u8fc7\u952e\u76d8\u548c\u9f20\u6807\u83b7\u5f97\u7126\u70b9 \u2022 Qt::WheelFocus&#xff1a;\u63a7\u4ef6\u53ef\u4ee5\u901a\u8fc7\u9f20\u6807\u6eda\u8f6e\u83b7\u5f97\u7126\u70b9&#xff08;\u5728\u67d0\u4e9b\u5e73\u53f0\u6216\u6837\u5f0f\u4e2d\u53ef\u80fd\u4e0d\u53ef\u7528&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>contextMenuPolicy<\/td>\n<td>\u4e0a\u4e0b\u6587\u83dc\u5355\u7684\u663e\u793a\u7b56\u7565\u3002 \u2022 Qt::DefaultContextMenu&#xff1a;\u9ed8\u8ba4\u7684\u4e0a\u4e0b\u6587\u83dc\u5355\u7b56\u7565&#xff0c;\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u9f20\u6807\u53f3\u952e\u6216\u952e\u76d8\u5feb\u6377\u952e\u89e6\u53d1\u4e0a\u4e0b\u6587\u83dc\u5355 \u2022 Qt::NoContextMenu&#xff1a;\u7981\u7528\u4e0a\u4e0b\u6587\u83dc\u5355&#xff0c;\u5373\u4f7f\u7528\u6237\u70b9\u51fb\u9f20\u6807\u53f3\u952e\u4e5f\u4e0d\u4f1a\u663e\u793a\u83dc\u5355 \u2022 Qt::PreventContextMenu&#xff1a;\u9632\u6b62\u63a7\u4ef6\u663e\u793a\u4e0a\u4e0b\u6587\u83dc\u5355&#xff0c;\u5373\u4f7f\u7528\u6237\u70b9\u51fb\u9f20\u6807\u53f3\u952e\u4e5f\u4e0d\u4f1a\u663e\u793a\u83dc\u5355 \u2022 Qt::ActionsContextMenu&#xff1a;\u5c06\u4e0a\u4e0b\u6587\u83dc\u5355\u66ff\u6362\u4e3a\u63a7\u4ef6\u7684\u201c\u52a8\u4f5c\u201d\u83dc\u5355&#xff0c;\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u9f20\u6807\u53f3\u952e\u6216\u952e\u76d8\u5feb\u6377\u952e\u89e6\u53d1\u8fd9\u4e2a\u83dc\u5355 \u2022 Qt::CustomContextMenu&#xff1a;\u4f7f\u7528\u81ea\u5b9a\u4e49\u7684\u4e0a\u4e0b\u6587\u83dc\u5355&#xff0c;\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u9f20\u6807\u53f3\u952e\u6216\u952e\u76d8\u5feb\u6377\u952e\u89e6\u53d1\u8fd9\u4e2a\u83dc\u5355<\/td>\n<\/tr>\n<tr>\n<td>locale<\/td>\n<td>\u8bbe\u7f6e\u8bed\u8a00\u548c\u56fd\u5bb6\u5730\u533a\u3002<\/td>\n<\/tr>\n<tr>\n<td>acceptDrops<\/td>\n<td>\u8be5\u90e8\u4ef6\u662f\u5426\u63a5\u53d7\u62d6\u653e\u64cd\u4f5c\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true&#xff0c;\u90a3\u4e48\u8be5\u90e8\u4ef6\u5c31\u53ef\u4ee5\u63a5\u6536\u6765\u81ea\u5176\u4ed6\u90e8\u4ef6\u7684\u62d6\u653e\u64cd\u4f5c&#xff0c;\u5f53\u4e00\u4e2a\u90e8\u4ef6\u88ab\u62d6\u653e\u5230\u8be5\u90e8\u4ef6\u4e0a\u65f6&#xff0c;\u8be5\u90e8\u4ef6\u4f1a\u63a5\u6536\u5230\u76f8\u5e94\u7684\u62d6\u653e\u4e8b\u4ef6&#xff08;\u5982 dropEvent&#xff09;\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a false&#xff0c;\u90a3\u4e48\u8be5\u90e8\u4ef6\u5c06\u4e0d\u4f1a\u63a5\u6536\u4efb\u4f55\u62d6\u653e\u64cd\u4f5c\u3002<\/td>\n<\/tr>\n<tr>\n<td>minimumSize<\/td>\n<td>\u63a7\u4ef6\u7684\u6700\u5c0f\u5c3a\u5bf8\u3002\u5305\u542b\u6700\u5c0f\u5bbd\u5ea6\u548c\u6700\u5c0f\u9ad8\u5ea6\u3002<\/td>\n<\/tr>\n<tr>\n<td>maximumSize<\/td>\n<td>\u63a7\u4ef6\u7684\u6700\u5927\u5c3a\u5bf8\u3002\u5305\u542b\u6700\u5927\u5bbd\u5ea6\u548c\u6700\u5927\u9ad8\u5ea6\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">sizePolicy<\/span><\/td>\n<td>\u5c3a\u5bf8\u7b56\u7565\u3002\u8bbe\u7f6e\u63a7\u4ef6\u5728\u5e03\u5c40\u7ba1\u7406\u5668\u4e2d\u7684\u7f29\u653e\u65b9\u5f0f\u3002<\/td>\n<\/tr>\n<tr>\n<td>windowModality<\/td>\n<td>\u6307\u5b9a\u7a97\u53e3\u662f\u5426\u5177\u6709\u201c\u6a21\u6001\u201d\u884c\u4e3a\u3002<\/td>\n<\/tr>\n<tr>\n<td>sizeIncrement<\/td>\n<td>\u62d6\u52a8\u7a97\u53e3\u5927\u5c0f\u65f6\u7684\u589e\u91cf\u5355\u4f4d\u3002<\/td>\n<\/tr>\n<tr>\n<td>baseSize<\/td>\n<td>\u7a97\u53e3\u7684\u57fa\u7840\u5927\u5c0f&#xff0c;\u7528\u6765\u642d\u914d sizeIncrement \u8c03\u6574\u7ec4\u4ef6\u5c3a\u5bf8\u65f6\u8ba1\u7b97\u7ec4\u4ef6\u5e94\u8be5\u8c03\u6574\u5230\u7684\u5408\u9002\u7684\u503c\u3002<\/td>\n<\/tr>\n<tr>\n<td>palette<\/td>\n<td>\u8c03\u8272\u677f\u3002\u53ef\u4ee5\u8bbe\u7f6e widget \u7684\u989c\u8272\u98ce\u683c\u3002<\/td>\n<\/tr>\n<tr>\n<td>mouseTracking<\/td>\n<td>\u662f\u5426\u8981\u8ddf\u8e2a\u9f20\u6807\u79fb\u52a8\u4e8b\u4ef6\u3002\u5982\u679c\u8bbe\u4e3a true&#xff0c;\u8868\u793a\u9700\u8981\u8ddf\u8e2a&#xff0c;\u5219\u9f20\u6807\u5212\u8fc7\u7684\u65f6\u5019\u8be5 widget \u5c31\u80fd\u6301\u7eed\u6536\u5230\u9f20\u6807\u79fb\u52a8\u4e8b\u4ef6\u3002\u5982\u679c\u8bbe\u4e3a false&#xff0c;\u8868\u793a\u4e0d\u9700\u8981\u8ddf\u8e2a&#xff0c;\u5219\u9f20\u6807\u5212\u8fc7\u7684\u65f6\u5019 widget \u4e0d\u4f1a\u6536\u5230\u9f20\u6807\u79fb\u52a8\u4e8b\u4ef6&#xff0c;\u53ea\u80fd\u6536\u5230\u9f20\u6807\u6309\u4e0b\u6216\u8005\u91ca\u653e\u7684\u4e8b\u4ef6\u3002<\/td>\n<\/tr>\n<tr>\n<td>tabletTracking<\/td>\n<td>\u662f\u5426\u8ddf\u8e2a\u89e6\u6478\u5c4f\u7684\u79fb\u52a8\u4e8b\u4ef6&#xff0c;\u7c7b\u4f3c\u4e8e mouseTracking\u3002Qt 5.9 \u4e2d\u5f15\u5165\u7684\u65b0\u5c5e\u6027\u3002<\/td>\n<\/tr>\n<tr>\n<td>layoutDirection<\/td>\n<td>\u5e03\u5c40\u65b9\u5411\u3002 \u2022 Qt::LeftToRight&#xff1a;\u6587\u672c\u4ece\u5de6\u5230\u53f3\u6392\u5217&#xff0c;\u4e5f\u662f\u9ed8\u8ba4\u503c\u3002 \u2022 Qt::RightToLeft&#xff1a;\u6587\u672c\u4ece\u53f3\u5230\u5de6\u6392\u5217\u3002 \u2022 Qt::GlobalAtomics&#xff1a;\u90e8\u4ef6\u7684\u5e03\u5c40\u65b9\u5411\u7531\u5168\u5c40\u539f\u5b50\u6027\u51b3\u5b9a&#xff08;\u5176\u5b9e\u5c31\u662f\u6839\u636e\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u5176\u4ed6 widget \u5e03\u5c40\u65b9\u5411\u786e\u5b9a\u7684&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td>autoFillBackground<\/td>\n<td>\u662f\u5426\u81ea\u52a8\u586b\u5145\u80cc\u666f\u989c\u8272\u3002<\/td>\n<\/tr>\n<tr>\n<td>windowFilePath<\/td>\n<td>\u80fd\u591f\u628a widget \u548c\u4e00\u4e2a\u672c\u5730\u6587\u4ef6\u8def\u5f84\u5173\u8054\u8d77\u6765\u3002PS&#xff1a;\u5176\u5b9e\u4f5c\u7528\u4e0d\u5927\u3002<\/td>\n<\/tr>\n<tr>\n<td>accessibleName<\/td>\n<td>\u8bbe\u7f6e widget \u7684\u53ef\u8bbf\u95ee\u540d\u79f0\u3002\u8fd9\u4e2a\u540d\u79f0\u53ef\u4ee5\u88ab\u8f85\u52a9\u6280\u672f&#xff08;\u50cf\u5c4f\u5e55\u9605\u8bfb\u5668&#xff09;\u83b7\u53d6\u5230\u3002\u8fd9\u4e2a\u5c5e\u6027\u7528\u4e8e\u5b9e\u73b0\u65e0\u969c\u788d\u7a0b\u5e8f\u7684\u573a\u666f\u4e2d&#xff08;\u4e5f\u5c31\u662f\u7ed9\u76f2\u4eba\u5199\u7684\u7a0b\u5e8f&#xff09;\u3002PS&#xff1a;\u5176\u5b9e\u76f2\u4eba\u4e5f\u662f\u53ef\u4ee5\u4f7f\u7528\u7535\u8111\u548c\u624b\u673a\u7684&#xff0c;\u751a\u81f3\u76f2\u4eba\u8fd8\u80fd\u6210\u4e3a\u7a0b\u5e8f\u733f\u3002\u53c2\u89c1 https:\/\/www.bilibili.com\/video\/BV1954y1d7z9<\/td>\n<\/tr>\n<tr>\n<td>accessibleDescription<\/td>\n<td>\u8bbe\u7f6e widget \u7684\u8be6\u7ec6\u63cf\u8ff0\u3002\u4f5c\u7528\u540c accessibleName\u3002<\/td>\n<\/tr>\n<tr>\n<td>inputMethodHints<\/td>\n<td>\u9488\u5bf9\u8f93\u5165\u6846\u6709\u6548&#xff0c;\u7528\u6765\u63d0\u793a\u7528\u6237\u5f53\u524d\u80fd\u8f93\u5165\u7684\u5408\u6cd5\u6570\u636e\u7684\u683c\u5f0f\u3002\u6bd4\u5982\u53ea\u80fd\u8f93\u5165\u6570\u5b57&#xff0c;\u53ea\u80fd\u8f93\u5165\u65e5\u671f\u7b49\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"2.2%20enabled%EF%BC%88%E6%8E%A7%E4%BB%B6%E4%BD%BF%E8%83%BD%EF%BC%89\">2.2 enabled&#xff08;\u63a7\u4ef6\u4f7f\u80fd&#xff09;<\/h3>\n<table>\n<tr>API\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#fe2c24\">isEnabled()<\/span><\/td>\n<td>\u83b7\u53d6\u5230\u63a7\u4ef6\u7684\u53ef\u7528\u72b6\u6001\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">setEnabled<\/span><\/td>\n<td>\u8bbe\u7f6e\u63a7\u4ef6\u662f\u5426\u53ef\u4f7f\u7528\u3002true \u8868\u793a\u53ef\u7528&#xff0c;false \u8868\u793a\u7981\u7528\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>\u201c\u7981\u7528\u201d&#xff1a;\u6307\u7684\u662f\u8be5\u63a7\u4ef6\u4e0d\u80fd\u63a5\u6536\u4efb\u4f55\u7528\u6237\u7684\u8f93\u5165\u4e8b\u4ef6&#xff0c;\u5e76\u4e14\u5916\u89c2\u4e0a\u5f80\u5f80\u662f\u7070\u8272\u7684\u3002<\/li>\n<li>\u5982\u679c\u4e00\u4e2a widget \u88ab\u7981\u7528&#xff0c;\u5219\u8be5 widget \u7684\u5b50\u5143\u7d20\u4e5f\u88ab\u7981\u7528\u3002<\/li>\n<\/ul>\n<p>Widget::Widget(QWidget *parent)<br \/>\n : QWidget(parent)<br \/>\n , ui(new Ui::Widget)<br \/>\n{<br \/>\n     ui-&gt;setupUi(this);<br \/>\n     QPushButton* btn &#061; new QPushButton(this);<br \/>\n     btn-&gt;setText(&#034;\u8fd9\u662f\u4e2a\u88ab\u7981\u2f64\u7684\u6309\u94ae&#034;);<br \/>\n     btn-&gt;setEnabled(false);<br \/>\n}<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"646\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011751-6ae29ebfc9e74.png\" width=\"804\" \/><\/p>\n<h3 id=\"2.3%20geometry%EF%BC%88%E4%BD%8D%E7%BD%AE%2F%E5%B0%BA%E5%AF%B8%EF%BC%89\">2.3 geometry&#xff08;\u4f4d\u7f6e\/\u5c3a\u5bf8&#xff09;<\/h3>\n<p>\u4f4d\u7f6e\u548c\u5c3a\u5bf8\u3002\u5176\u5b9e\u662f\u56db\u4e2a\u5c5e\u6027\u7684\u7edf\u79f0&#xff1a;<\/p>\n<ul>\n<li>x \u6a2a\u5750\u6807<\/li>\n<li>y \u7eb5\u5750\u6807<\/li>\n<li>width \u5bbd\u5ea6<\/li>\n<li>height \u9ad8\u5ea6<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"576\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011752-6ae29ec00684f.png\" width=\"776\" \/><\/p>\n<ul>\n<li>\u5b9e\u9645\u5f00\u53d1\u4e2d&#xff0c;\u5e76\u4e0d\u4f1a\u76f4\u63a5\u4f7f\u7528\u8fd9\u51e0\u4e2a\u5c5e\u6027&#xff0c;\u800c\u662f\u901a\u8fc7\u4e00\u7cfb\u5217\u5c01\u88c5\u7684\u65b9\u6cd5\u6765\u83b7\u53d6\/\u4fee\u6539\u3002<\/li>\n<li>Qt \u7684\u5750\u6807\u7cfb\u662f\u4e00\u4e2a\u201c\u5de6\u624b\u5750\u6807\u7cfb\u201d&#xff0c;\u5176\u4e2d\u5750\u6807\u7cfb\u7684\u539f\u70b9\u662f\u5f53\u524d\u5143\u7d20\u7684\u7236\u5143\u7d20\u7684\u5de6\u4e0a\u89d2\u3002<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"451\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011752-6ae29ec034ed3.png\" width=\"659\" \/><\/p>\n<table>\n<tr>API\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#fe2c24\">geometry()<\/span><\/td>\n<td>\u83b7\u53d6\u5230\u63a7\u4ef6\u7684\u4f4d\u7f6e\u548c\u5c3a\u5bf8\u3002\u8fd4\u56de\u7ed3\u679c\u662f\u4e00\u4e2a QRect&#xff0c;\u5305\u542b\u4e86 x\u3001y\u3001width\u3001height&#xff0c;\u5176\u4e2d x\u3001y \u662f\u5de6\u4e0a\u89d2\u7684\u5750\u6807\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">setGeometry(QRect)<\/span> <span style=\"color:#fe2c24\">setGeometry(int x, int y, int width, int height)<\/span><\/td>\n<td>\u8bbe\u7f6e\u63a7\u4ef6\u7684\u4f4d\u7f6e\u548c\u5c3a\u5bf8\u3002\u53ef\u4ee5\u76f4\u63a5\u8bbe\u7f6e\u4e00\u4e2a QRect&#xff0c;\u4e5f\u53ef\u4ee5\u5206\u56db\u4e2a\u5c5e\u6027\u5355\u72ec\u8bbe\u7f6e\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E6%8E%A7%E5%88%B6%E6%8C%89%E9%92%AE%E7%9A%84%E4%BD%8D%E7%BD%AE\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u63a7\u5236\u6309\u94ae\u7684\u4f4d\u7f6e<\/h4>\n<p>\u5728\u754c\u9762\u4e2d\u62d6\u4e94\u4e2a\u6309\u94ae\u3002\u4e94\u4e2a\u6309\u94ae\u7684 objectName \u5206\u522b\u4e3a<\/p>\n<ul>\n<li>pushButton_target<\/li>\n<li>pushButton_up<\/li>\n<li>pushButton_down<\/li>\n<li>pushButton_left<\/li>\n<li>pushButton_right<\/li>\n<\/ul>\n<p># widget.cpp<\/p>\n<p>void Widget::on_pushButton_up_clicked()<br \/>\n{<br \/>\n     QRect rect &#061; ui-&gt;pushButton_target-&gt;geometry();<br \/>\n     rect.setY(rect.y() &#8211; 5);<br \/>\n     ui-&gt;pushButton_target-&gt;setGeometry(rect);<br \/>\n}<\/p>\n<p>void Widget::on_pushButton_down_clicked()<br \/>\n{<br \/>\n     QRect rect &#061; ui-&gt;pushButton_target-&gt;geometry();<br \/>\n     rect.setY(rect.y() &#043; 5);<br \/>\n     ui-&gt;pushButton_target-&gt;setGeometry(rect);<br \/>\n}<\/p>\n<p>void Widget::on_pushButton_left_clicked()<br \/>\n{<br \/>\n     QRect rect &#061; ui-&gt;pushButton_target-&gt;geometry();<br \/>\n     rect.setX(rect.x() &#8211; 5);<br \/>\n     ui-&gt;pushButton_target-&gt;setGeometry(rect);<br \/>\n}<\/p>\n<p>void Widget::on_pushButton_right_clicked()<br \/>\n{<br \/>\n     QRect rect &#061; ui-&gt;pushButton_target-&gt;geometry();<br \/>\n     rect.setX(rect.x() &#043; 5);<br \/>\n     ui-&gt;pushButton_target-&gt;setGeometry(rect);<br \/>\n}<\/p>\n<p>\u8fd0\u884c\u7a0b\u5e8f&#xff0c;\u53ef\u4ee5\u770b\u5230&#xff0c;\u6309\u4e0b\u4e0b\u65b9\u7684\u56db\u4e2a\u6309\u94ae&#xff0c;\u5c31\u4f1a\u63a7\u5236 target \u7684\u5de6\u4e0a\u89d2\u7684\u4f4d\u7f6e\u3002\u5bf9\u5e94\u7684\u6309\u94ae\u6574\u4e2a\u5c3a\u5bf8\u4e5f\u4f1a\u53d1\u751f\u6539\u53d8\u3002<\/p>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u4e2d\u6211\u4eec\u662f\u76f4\u63a5\u8bbe\u7f6e\u7684 QRect \u4e2d\u7684 x&#xff0c;y\u3002\u5b9e\u9645\u4e0a QRect \u5185\u90e8\u662f\u5b58\u50a8\u4e86\u5de6\u4e0a\u548c\u53f3\u4e0b\u4e24\u4e2a\u70b9\u7684\u5750\u6807&#xff0c;\u518d\u901a\u8fc7\u8fd9\u4e24\u4e2a\u70b9\u7684\u5750\u6807\u5dee\u503c\u8ba1\u7b97\u957f\u5bbd\u3002<span style=\"color:#fe2c24\">\u5355\u7eaf\u4fee\u6539\u5de6\u4e0a\u5750\u6807\u5c31\u4f1a\u5f15\u8d77\u6574\u4e2a\u77e9\u5f62\u7684\u957f\u5bbd\u53d1\u751f\u6539\u53d8\u3002<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"640\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011752-6ae29ec04f040.png\" width=\"797\" \/><\/p>\n<ul>\n<li>\u5982\u679c\u60f3\u8ba9\u6574\u4e2a\u6309\u94ae\u90fd\u79fb\u52a8&#xff0c;\u53ef\u4ee5\u6539\u6210\u4e0b\u5217\u4ee3\u7801&#xff1a;<\/li>\n<li>\u6216\u8005\u53ef\u4ee5\u4f7f\u7528move\u5b9e\u73b0<\/li>\n<\/ul>\n<p>void Widget::on_pushButton_up_clicked()<br \/>\n{<br \/>\n     QRect rect &#061; ui-&gt;pushButton_target-&gt;geometry();<br \/>\n     ui-&gt;pushButton_target-&gt;setGeometry(rect.x(), rect.y() &#8211; 5, rect.width(),<br \/>\nrect.height());<\/p>\n<p>}<\/p>\n<p>void Widget::on_pushButton_down_clicked()<br \/>\n{<br \/>\n     QRect rect &#061; ui-&gt;pushButton_target-&gt;geometry();<br \/>\n     ui-&gt;pushButton_target-&gt;setGeometry(rect.x(), rect.y() &#043; 5, rect.width(),<br \/>\nrect.height());<br \/>\n}<\/p>\n<p>void Widget::on_pushButton_left_clicked()<br \/>\n{<br \/>\n     QRect rect &#061; ui-&gt;pushButton_target-&gt;geometry();<br \/>\n     ui-&gt;pushButton_target-&gt;setGeometry(rect.x() &#8211; 5, rect.y(), rect.width(),<br \/>\nrect.height());<br \/>\n}<\/p>\n<p>void Widget::on_pushButton_right_clicked()<br \/>\n{<br \/>\n     QRect rect &#061; ui-&gt;pushButton_target-&gt;geometry();<br \/>\n     ui-&gt;pushButton_target-&gt;setGeometry(rect.x() &#043; 5, rect.y(), rect.width(),<br \/>\nrect.height());<br \/>\n}<\/p>\n<h4 id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E4%B8%80%E4%B8%AA%E8%A1%A8%E7%99%BD%E7%A8%8B%E5%BA%8F\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u4e00\u4e2a\u8868\u767d\u7a0b\u5e8f<\/h4>\n<p>\u5f80\u754c\u9762\u4e0a\u62d6\u62fd\u4e24\u4e2a\u6309\u94ae\u548c\u4e00\u4e2a Label\u3002PushButton\u7684 objectName \u4e3a<\/p>\n<ul>\n<li>pushButton_accept<\/li>\n<li>pushButton_reject<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"600\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011752-6ae29ec07fe96.png\" width=\"803\" \/><\/p>\n<p># \u5728 widget.cpp \u4e2d\u6dfb\u52a0 slot \u51fd\u6570\u3002<br \/>\noid Widget::on_pushButton_accept_clicked()<br \/>\n{<br \/>\n     ui-&gt;label-&gt;setText(&#034;\u2f25\u795e\u5feb\u6765\u5634\u2f00\u4e2a! mua~~&#034;);<br \/>\n}<\/p>\n<p>void Widget::on_pushButton_reject_pressed()<br \/>\n{<br \/>\n     \/\/ \u83b7\u53d6\u7a97\u2f1d\u7684\u5bbd\u5ea6\u548c\u2fbc\u5ea6<br \/>\n     int width &#061; this-&gt;geometry().width();<br \/>\n     int height &#061; this-&gt;geometry().height();<br \/>\n     \/\/ \u91cd\u65b0\u2f63\u6210\u6309\u94ae\u7684\u4f4d\u7f6e.<br \/>\n     int x &#061; rand() % width;<br \/>\n     int y &#061; rand() % height;<br \/>\n     \/\/ \u8bbe\u7f6e\u65b0\u7684\u4f4d\u7f6e<br \/>\n     ui-&gt;pushButton_reject-&gt;move(x, y);<br \/>\n}<\/p>\n<ul>\n<li>\u8fd0\u884c\u7a0b\u5e8f&#xff0c;\u53ef\u4ee5\u770b\u5230&#xff0c;\u5f53\u70b9\u51fb\u201c\u6b8b\u5fcd\u62d2\u7edd\u201d\u65f6&#xff0c;\u6309\u94ae\u5c31\u8dd1\u4e86\u3002<\/li>\n<li><span style=\"color:#fe2c24\">\u4e0a\u8ff0\u4ee3\u7801\u4f7f\u7528\u7684\u662f pressed&#xff0c;\u9f20\u6807\u6309\u4e0b\u5c31\u4ea7\u751f\u4fe1\u53f7&#xff08;\u4e0d\u7528\u5f39\u8d77&#xff09;<\/span>\u3002\u5982\u679c\u4f7f\u7528 mouseMoveEvent&#xff0c;\u4f1a\u66f4\u72e0\u4e00\u4e9b&#xff0c;\u53ea\u8981\u9f20\u6807\u79fb\u52a8\u8fc7\u6765&#xff0c;\u6309\u94ae\u5c31\u8dd1\u4e86\u3002\u5bf9\u5e94\u7684\u4ee3\u7801\u66f4\u9ebb\u70e6\u4e00\u4e9b&#xff08;\u9700\u8981\u81ea\u5b9a\u4e49\u7c7b\u7ee7\u627f\u81ea QPushButton&#xff0c;\u91cd\u5199 mouseMoveEvent \u65b9\u6cd5&#xff09;\u3002\u6b64\u5904\u6682\u65f6\u4e0d\u5c55\u5f00\u3002<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"639\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011752-6ae29ec0b1e75.png\" width=\"799\" \/><\/p>\n<h4 id=\"window%20frame%20%E7%9A%84%E5%BD%B1%E5%93%8D\">window frame \u7684\u5f71\u54cd<\/h4>\n<p>\u5982\u679c widget \u4f5c\u4e3a\u4e00\u4e2a\u7a97\u53e3&#xff08;\u5e26\u6709\u6807\u9898\u680f&#xff0c;\u6700\u5c0f\u5316&#xff0c;\u6700\u5927\u5316&#xff0c;\u5173\u95ed\u6309\u94ae&#xff09;&#xff0c;\u90a3\u4e48\u5728\u8ba1\u7b97\u5c3a\u5bf8\u548c\u5750\u6807\u7684\u65f6\u5019\u5c31\u6709\u4e24\u79cd\u7b97\u6cd5\u3002\u5305\u542b window frame \u548c\u4e0d\u5305\u542b window frame\u3002<\/p>\n<\/p>\n<p>\u5176\u4e2d x()&#xff0c;y()&#xff0c;frameGeometry()&#xff0c;pos()&#xff0c;move() \u90fd\u662f\u6309\u7167\u5305\u542b window frame \u7684\u65b9\u5f0f\u6765\u8ba1\u7b97\u7684\u3002<\/p>\n<\/p>\n<p>\u5176\u4e2d geometry()&#xff0c;width()&#xff0c;height()&#xff0c;rect()&#xff0c;size() \u5219\u662f\u6309\u7167\u4e0d\u5305\u542b window frame \u7684\u65b9\u5f0f\u6765\u8ba1\u7b97\u7684\u3002<\/p>\n<\/p>\n<p>\u5f53\u7136&#xff0c;\u5982\u679c\u4e00\u4e2a\u4e0d\u662f\u4f5c\u4e3a\u7a97\u53e3\u7684 widget&#xff0c;\u4e0a\u8ff0\u4e24\u7c7b\u65b9\u5f0f\u5f97\u5230\u7684\u7ed3\u679c\u662f\u4e00\u81f4\u7684\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"395\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011752-6ae29ec0e3e5e.png\" width=\"567\" \/><\/p>\n<table>\n<tr>API\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#fe2c24\">x()<\/span><\/td>\n<td>\u83b7\u53d6\u6a2a\u5750\u6807&#xff0c;\u8ba1\u7b97\u65f6\u5305\u542b window frame\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">y()<\/span><\/td>\n<td>\u83b7\u53d6\u7eb5\u5750\u6807&#xff0c;\u8ba1\u7b97\u65f6\u5305\u542b window frame\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">pos()<\/span><\/td>\n<td>\u8fd4\u56de QPoint \u5bf9\u8c61&#xff0c;\u91cc\u9762\u5305\u542b x()\u3001y()\u3001setX()\u3001setY() \u7b49\u65b9\u6cd5\u3002\u8ba1\u7b97\u65f6\u5305\u542b window frame\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">frameSize()<\/span><\/td>\n<td>\u8fd4\u56de QSize \u5bf9\u8c61&#xff0c;\u91cc\u9762\u5305\u542b width()\u3001height()\u3001setWidth()\u3001setHeight() \u7b49\u65b9\u6cd5\u3002\u8ba1\u7b97\u65f6\u5305\u542b window frame\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">frameGeometry()<\/span><\/td>\n<td>\u8fd4\u56de QRect \u5bf9\u8c61\u3002QRect \u76f8\u5f53\u4e8e QPoint \u548c QSize \u7684\u7ed3\u5408\u4f53&#xff0c;\u53ef\u4ee5\u83b7\u53d6 x\u3001y\u3001width\u3001size\u3002\u8ba1\u7b97\u65f6\u5305\u542b window frame \u5bf9\u8c61\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">width()<\/span><\/td>\n<td>\u83b7\u53d6\u5bbd\u5ea6&#xff0c;\u8ba1\u7b97\u65f6\u4e0d\u5305\u542b window frame\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">height()<\/span><\/td>\n<td>\u83b7\u53d6\u9ad8\u5ea6&#xff0c;\u8ba1\u7b97\u65f6\u4e0d\u5305\u542b window frame\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">size()<\/span><\/td>\n<td>\u8fd4\u56de QSize \u5bf9\u8c61&#xff0c;\u91cc\u9762\u5305\u542b width()\u3001height()\u3001setWidth()\u3001setHeight() \u7b49\u65b9\u6cd5\u3002\u8ba1\u7b97\u65f6\u4e0d\u5305\u542b window frame\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">rect()<\/span><\/td>\n<td>\u8fd4\u56de QRect \u5bf9\u8c61\u3002QRect \u76f8\u5f53\u4e8e QPoint \u548c QSize \u7684\u7ed3\u5408\u4f53&#xff0c;\u53ef\u4ee5\u83b7\u53d6\u5e76\u8bbe\u7f6e x\u3001y\u3001width\u3001size\u3002\u8ba1\u7b97\u65f6\u4e0d\u5305\u542b window frame \u5bf9\u8c61\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">geometry()<\/span><\/td>\n<td>\u8fd4\u56de QRect \u5bf9\u8c61\u3002QRect \u76f8\u5f53\u4e8e QPoint \u548c QSize \u7684\u7ed3\u5408\u4f53&#xff0c;\u53ef\u4ee5\u83b7\u53d6 x\u3001y\u3001width\u3001size\u3002\u8ba1\u7b97\u65f6\u4e0d\u5305\u542b window frame \u5bf9\u8c61\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">setGeometry()<\/span><\/td>\n<td>\u76f4\u63a5\u8bbe\u7f6e\u7a97\u53e3\u7684\u4f4d\u7f6e\u548c\u5c3a\u5bf8&#xff0c;\u53ef\u4ee5\u8bbe\u7f6e x\u3001y\u3001width\u3001height&#xff0c;\u6216\u8005 QRect \u5bf9\u8c61\u3002\u8ba1\u7b97\u65f6\u4e0d\u5305\u542b window frame \u5bf9\u8c61\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8ba4\u771f\u89c2\u5bdf\u4e0a\u9762\u7684\u8868\u683c&#xff0c;\u53ef\u4ee5\u770b\u5230&#xff0c;\u5176\u5b9e\u8fd9\u91cc\u7684 API \u6709 frameGeometry \u548c geometry \u4e24\u4e2a\u5c31\u8db3\u591f\u5b8c\u6210\u6240\u6709\u7684\u9700\u6c42\u4e86\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48\u8981\u63d0\u4f9b\u8fd9\u4e48\u591a\u529f\u80fd\u91cd\u590d\u7684 API \u5462&#xff1f;<\/p>\n<p>\u8fd9\u4e2a\u5c31\u6d89\u53ca\u5230 Qt API \u7684\u8bbe\u8ba1\u7406\u5ff5\u4e86&#xff1a;\u5c3d\u91cf\u7b26\u5408\u4eba\u7684\u76f4\u89c9\u3002<\/p>\n<\/p>\n<p>\u4e3e\u4e2a\u4f8b\u5b50&#xff0c;Qt \u7684 QVector&#xff0c;\u5c3e\u63d2\u5143\u7d20\u64cd\u4f5c&#xff0c;\u6709\u4ee5\u4e0b\u65b9\u6cd5&#xff1a;<\/p>\n<ul>\n<li>push_back<\/li>\n<li>append<\/li>\n<li>&#043;&#061;<\/li>\n<li>&lt;&lt;<\/li>\n<\/ul>\n<p>\u4e0a\u8ff0\u65b9\u6cd5\u7684\u6548\u679c\u90fd\u662f\u7b49\u4ef7\u7684\u3002\u5373\u4f7f\u4e0d\u7ffb\u9605\u6587\u6863&#xff0c;\u5355\u7eaf\u7684\u51ed\u501f\u76f4\u89c9\u5c31\u80fd\u628a\u4ee3\u7801\u5199\u5bf9\u3002<\/p>\n<p># \u6309\u94ae\u7684slot\u69fd\u51fd\u6570\u4e2d<br \/>\nvoid Widget::on_pushButton_clicked()<br \/>\n{<br \/>\n     QRect rect1 &#061; this-&gt;geometry();<br \/>\n     QRect rect2 &#061; this-&gt;frameGeometry();<br \/>\n     qDebug() &lt;&lt; rect1;<br \/>\n     qDebug() &lt;&lt; rect2;<br \/>\n}<\/p>\n<p># widget\u6784\u9020\u51fd\u6570\u4e2d<br \/>\nWidget::Widget(QWidget *parent)<br \/>\n : QWidget(parent)<br \/>\n , ui(new Ui::Widget)<br \/>\n{<br \/>\n     ui-&gt;setupUi(this);<br \/>\n     QRect rect1 &#061; this-&gt;geometry();<br \/>\n     QRect rect2 &#061; this-&gt;frameGeometry();<br \/>\n     qDebug() &lt;&lt; rect1;<br \/>\n     qDebug() &lt;&lt; rect2;<br \/>\n}<\/p>\n<p>\u6267\u884c\u7a0b\u5e8f&#xff0c;\u53ef\u4ee5\u770b\u5230&#xff0c;\u6784\u9020\u51fd\u6570\u4e2d&#xff0c;\u6253\u5370\u51fa\u7684 geometry \u548c frameGeometry \u662f\u76f8\u540c\u7684\u3002<\/p>\n<p>\u4f46\u662f\u5728\u70b9\u51fb\u6309\u94ae\u65f6&#xff0c;\u6253\u5370\u7684 geometry \u548c frameGeometry \u5219\u5b58\u5728\u5dee\u5f02\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"136\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011753-6ae29ec1097a2.png\" width=\"379\" \/><\/p>\n<p>\u539f\u56e0&#xff1a;<\/p>\n<p>\u5728\u6784\u9020\u65b9\u6cd5\u4e2d&#xff0c;Widget \u521a\u521a\u521b\u5efa\u51fa\u6765&#xff0c;\u8fd8\u6ca1\u6709\u52a0\u5165\u5230\u5bf9\u8c61\u6811\u4e2d\u3002\u6b64\u65f6\u4e5f\u5c31\u4e0d\u5177\u5907 Window frame\u3002<\/p>\n<p>\u5728\u6309\u94ae\u7684 slot \u51fd\u6570\u4e2d&#xff0c;\u7531\u4e8e\u7528\u6237\u70b9\u51fb\u7684\u65f6\u5019&#xff0c;\u5bf9\u8c61\u6811\u5df2\u7ecf\u6784\u9020\u597d\u4e86&#xff0c;\u6b64\u65f6 Widget \u5df2\u7ecf\u5177\u5907\u4e86 Window frame&#xff0c;\u56e0\u6b64\u5728\u4f4d\u7f6e\u548c\u5c3a\u5bf8\u4e0a\u5747\u51fa\u73b0\u4e86\u5dee\u5f02\u3002<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u5982\u679c\u628a\u4e0a\u8ff0\u4ee3\u7801\u4fee\u6539\u6210\u6253\u5370 pushButton \u7684 geometry \u548c frameGeometry&#xff0c;\u7ed3\u679c\u5c31\u662f\u5b8c\u5168\u76f8\u540c\u7684\u3002\u56e0\u4e3a pushButton \u5e76\u975e\u662f\u4e00\u4e2a\u7a97\u53e3\u3002<\/span><\/p>\n<h3 id=\"2.4%20windowTitle%EF%BC%88%E9%A1%B6%E5%B1%82%E7%AA%97%E5%8F%A3%E6%A0%87%E9%A2%98%EF%BC%89\">2.4 windowTitle&#xff08;\u9876\u5c42\u7a97\u53e3\u6807\u9898&#xff09;<\/h3>\n<table>\n<tr>API\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#fe2c24\">windowTitle()<\/span><\/td>\n<td>\u83b7\u53d6\u5230\u63a7\u4ef6\u7684\u7a97\u53e3\u6807\u9898\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">setWindowTitle(const QString&amp; title)<\/span><\/td>\n<td>\u8bbe\u7f6e\u63a7\u4ef6\u7684\u7a97\u53e3\u6807\u9898\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e0a\u8ff0\u8bbe\u7f6e\u64cd\u4f5c\u9488\u5bf9\u4e0d\u540c\u7684 widget \u53ef\u80fd\u4f1a\u6709\u4e0d\u540c\u7684\u884c\u4e3a\u3002<span style=\"color:#fe2c24\">\u5982\u679c\u662f\u9876\u5c42 widget&#xff08;\u72ec\u7acb\u7a97\u53e3&#xff09;&#xff0c;\u8fd9\u4e2a\u64cd\u4f5c\u624d\u4f1a\u6709\u6548\u3002\u5982\u679c\u662f\u5b50 widget&#xff0c;\u8fd9\u4e2a\u64cd\u4f5c\u65e0\u4efb\u4f55\u6548\u679c\u3002<\/span><\/p>\n<p># widget.cpp<br \/>\nWidget::Widget(QWidget *parent)<br \/>\n : QWidget(parent)<br \/>\n , ui(new Ui::Widget)<br \/>\n{<br \/>\n     ui-&gt;setupUi(this);<br \/>\n     \/\/ \u8bbe\u7f6e\u7a97\u2f1d\u6807\u9898<br \/>\n     this-&gt;setWindowTitle(&#034;\u8fd9\u662f\u6807\u9898&#034;);<br \/>\n}<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"637\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011753-6ae29ec11cb09.png\" width=\"798\" \/><\/p>\n<h3 id=\"2.5%20windowIcon%EF%BC%88%E9%A1%B6%E5%B1%82%E7%AA%97%E5%8F%A3%E5%9B%BE%E6%A0%87%EF%BC%89\">2.5 windowIcon&#xff08;\u9876\u5c42\u7a97\u53e3\u56fe\u6807&#xff09;<\/h3>\n<p>\u540c windowTitle&#xff0c;\u4e0a\u8ff0\u64cd\u4f5c<span style=\"color:#fe2c24\">\u4ec5\u9488\u5bf9\u9876\u5c42 widget \u6709\u6548\u3002<\/span><\/p>\n<table>\n<tr>API\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#fe2c24\">windowIcon()<\/span><\/td>\n<td>\u83b7\u53d6\u5230\u63a7\u4ef6\u7684\u7a97\u53e3\u56fe\u6807&#xff0c;\u8fd4\u56de QIcon \u5bf9\u8c61\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">setWindowIcon(const QIcon&amp; icon)<\/span><\/td>\n<td>\u8bbe\u7f6e\u63a7\u4ef6\u7684\u7a97\u53e3\u56fe\u6807\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E8%AE%BE%E7%BD%AE%E7%AA%97%E5%8F%A3%E5%9B%BE%E6%A0%87\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u8bbe\u7f6e\u7a97\u53e3\u56fe\u6807<\/h4>\n<p>\u5148\u5728 D \u76d8\u4e2d\u653e\u4e00\u4e2a\u56fe\u7247&#xff0c;\u540d\u5b57\u4e3a rose.jpg<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"220\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011753-6ae29ec14c9a2.png\" width=\"220\" \/><\/p>\n<p>#include &lt;QIcon&gt;<br \/>\nWidget::Widget(QWidget *parent)<br \/>\n : QWidget(parent)<br \/>\n , ui(new Ui::Widget)<br \/>\n{<br \/>\n     ui-&gt;setupUi(this);<br \/>\n     \/\/ \u521b\u5efa\u56fe\u6807\u5bf9\u8c61<br \/>\n     QIcon icon(&#034;d:\/rose.jpg&#034;);<br \/>\n     \/\/ \u8bbe\u7f6e\u56fe\u6807<br \/>\n     this-&gt;setWindowIcon(icon);<br \/>\n}<\/p>\n<p>\u6ce8\u610f&#xff1a;Windows \u4e0b\u8def\u5f84\u7684\u5206\u9694\u7b26\u53ef\u4ee5\u4f7f\u7528 \/ \u4e5f\u53ef\u4ee5\u4f7f\u7528 \\\\\u3002<span style=\"color:#fe2c24\">\u4f46\u662f\u5982\u679c\u5728\u5b57\u7b26\u4e32\u4e2d\u4f7f\u7528 \\\\&#xff0c;\u9700\u8981\u5199\u4f5c\u8f6c\u4e49\u5b57\u7b26\u7684\u5f62\u5f0f \\\\&#xff0c;\u5373 \\\\\\\\<\/span>&#xff0c;\u56e0\u6b64\u6211\u4eec\u8fd8\u662f\u66f4\u63a8\u8350\u4f7f\u7528 \/<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"563\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011753-6ae29ec15f121.png\" width=\"808\" \/><\/p>\n<p>\u4e0e\u6b64\u540c\u65f6&#xff0c;\u7a0b\u5e8f\u5728\u4efb\u52a1\u680f\u4e2d\u7684\u56fe\u6807\u4e5f\u53d1\u751f\u6539\u53d8\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"63\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011753-6ae29ec18bb23.png\" width=\"98\" \/><\/p>\n<p>\u5b9e\u9645\u5f00\u53d1\u4e2d&#xff0c;\u6211\u4eec\u4e00\u822c\u4e0d\u4f1a\u5728\u4ee3\u7801\u4e2d\u901a\u8fc7\u7edd\u5bf9\u8def\u5f84\u5f15\u5165\u56fe\u7247\u3002\u56e0\u4e3a\u6211\u4eec\u65e0\u6cd5\u4fdd\u8bc1\u7a0b\u5e8f\u53d1\u5e03\u540e&#xff0c;\u7528\u6237\u7684\u7535\u8111\u4e0a\u4e5f\u6709\u540c\u6837\u7684\u8def\u5f84\u3002<\/p>\n<p>\u5982\u679c\u4f7f\u7528\u76f8\u5bf9\u8def\u5f84&#xff0c;\u5219\u9700\u8981\u786e\u4fdd\u4ee3\u7801\u4e2d\u7684\u76f8\u5bf9\u8def\u5f84\u5199\u6cd5\u548c\u56fe\u7247\u5b9e\u9645\u6240\u5728\u7684\u8def\u5f84\u5339\u914d&#xff08;\u6bd4\u5982\u4ee3\u7801\u4e2d\u5199\u4f5c &#034;.\/image\/rose.jpg&#034;&#xff0c;\u5c31\u9700\u8981\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u521b\u5efa image \u76ee\u5f55&#xff0c;\u5e76\u628a rose.jpg \u653e\u8fdb\u53bb&#xff09;\u3002<\/p>\n<ul>\n<li>\u7edd\u5bf9\u8def\u5f84&#xff1a;\u4ee5\u76d8\u7b26&#xff08;windows&#xff09;\u6216\u8005\u4ee5 \/&#xff08;Linux&#xff09;\u5f00\u5934\u7684\u8def\u5f84\u3002<\/li>\n<li>\u76f8\u5bf9\u8def\u5f84&#xff1a;\u4ee5 .&#xff08;\u8868\u793a\u5f53\u524d\u8def\u5f84&#xff09;\u6216\u8005\u4ee5 ..&#xff08;\u8868\u793a\u5f53\u524d\u8def\u5f84\u4e0a\u7ea7\u8def\u5f84&#xff09;\u5f00\u5934\u7684\u8def\u5f84\u3002\u5176\u4e2d . \u7ecf\u5e38\u4e5f\u4f1a\u7701\u7565\u3002\u76f8\u5bf9\u8def\u5f84\u7684\u524d\u63d0\u662f\u9700\u8981\u660e\u786e\u201c\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u201d\u3002<\/li>\n<\/ul>\n<p>\u5bf9\u4e8e Qt \u7a0b\u5e8f\u6765\u8bf4&#xff0c;\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u53ef\u80fd\u662f\u53d8\u5316\u7684\u3002\u6bd4\u5982\u901a\u8fc7 Qt Creator \u8fd0\u884c\u7684\u7a0b\u5e8f&#xff0c;\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u662f\u9879\u76ee\u7684\u6784\u5efa\u76ee\u5f55&#xff1b;\u76f4\u63a5\u53cc\u51fb exe \u8fd0\u884c&#xff0c;\u5de5\u4f5c\u76ee\u5f55\u5219\u662f exe \u6240\u5728\u76ee\u5f55\u3002<\/p>\n<p><span style=\"color:#fe2c24\">\u6240\u8c13\u6784\u5efa\u76ee\u5f55&#xff0c;\u662f\u548c Qt \u9879\u76ee\u5e76\u5217\u7684&#xff0c;\u4e13\u95e8\u7528\u6765\u653e\u751f\u6210\u7684\u4e34\u65f6\u6587\u4ef6\u548c\u6700\u7ec8 exe \u7684\u76ee\u5f55\u3002<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"561\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011753-6ae29ec1987d4.png\" width=\"614\" \/><\/p>\n<h4 id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E8%8E%B7%E5%8F%96%E5%BD%93%E5%89%8D%E7%9A%84%E5%B7%A5%E4%BD%9C%E7%9B%AE%E5%BD%95\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u83b7\u53d6\u5f53\u524d\u7684\u5de5\u4f5c\u76ee\u5f55<\/h4>\n<ul>\n<li>\u4f7f\u7528 QDir::currentPath() \u5373\u53ef\u83b7\u53d6\u5230\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u3002<\/li>\n<li>\u663e\u793a\u5230 label \u4e0a<\/li>\n<\/ul>\n<p>#include &lt;QDir&gt;<br \/>\nWidget::Widget(QWidget *parent)<br \/>\n : QWidget(parent)<br \/>\n , ui(new Ui::Widget)<br \/>\n{<br \/>\n     ui-&gt;setupUi(this);<br \/>\n     \/\/ \u83b7\u53d6\u5230\u5f53\u524d\u2f2f\u4f5c\u2f6c\u5f55<br \/>\n     QString currentDir &#061; QDir::currentPath();<br \/>\n     \/\/ \u8bbe\u7f6e\u2f2f\u4f5c\u2f6c\u5f55\u5230 label \u4e2d.<br \/>\n     ui-&gt;label-&gt;setText(currentDir);<br \/>\n}<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"638\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011753-6ae29ec1b4cfb.png\" width=\"801\" \/><\/p>\n<p>\u8fdb\u5165\u4e0a\u8ff0\u6784\u5efa\u76ee\u5f55&#xff0c;\u628a\u91cc\u9762\u7684 exe \u62f7\u8d1d\u5230\u5176\u4ed6\u76ee\u5f55\u4e2d&#xff0c;\u6bd4\u5982 D: \u4e2d\u3002\u518d\u6b21\u6267\u884c\u7a0b\u5e8f&#xff0c;\u53ef\u4ee5\u770b\u5230\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u5df2\u7ecf\u53d1\u751f\u6539\u53d8\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"635\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011753-6ae29ec1ebfa3.png\" width=\"799\" \/><\/p>\n<p><span style=\"color:#fe2c24\">\u8981\u60f3\u76f4\u63a5\u80fd\u53cc\u51fb exe \u8fd0\u884c&#xff0c;\u9700\u8981\u5148\u628a Qt \u7684\u8def\u5f84\u6dfb\u52a0\u5230 path \u73af\u5883\u53d8\u91cf\u4e2d&#xff0c;\u5426\u5219\u4f1a\u63d0\u793a\u627e\u4e0d\u5230\u52a8\u6001\u5e93\u3002<\/span><\/p>\n<p>\u6ce8\u610f&#xff1a;\u4e0a\u8ff0\u6784\u5efa\u76ee\u5f55&#xff0c;\u662f\u968f\u65f6\u53ef\u5220\u9664\u7684\u3002\u6bd4\u5982\u70b9\u51fb\u83dc\u5355\u680f\u4e2d\u7684\u201c\u6784\u5efa\u201d-&gt;\u201c\u6e05\u7406\u9879\u76ee\u201d&#xff0c;\u5c31\u4f1a\u628a\u8fd9\u4e2a\u76ee\u5f55\u4e2d\u7684\u5185\u5bb9\u6e05\u7a7a\u6389\u3002<\/p>\n<\/p>\n<p>\u56e0\u6b64\u5982\u679c\u6211\u4eec\u628a\u56fe\u7247\u6587\u4ef6\u653e\u5230\u6784\u5efa\u76ee\u5f55\u4e2d&#xff0c;\u53ef\u80fd\u5728\u4e0d\u5c0f\u5fc3\u5220\u9664\u540e\u5c31\u4e22\u5931\u4e86\u3002\u6211\u4eec\u8fd8\u662f\u5e0c\u671b\u80fd\u591f\u628a\u56fe\u7247\u548c\u6e90\u4ee3\u7801\u653e\u5230\u4e00\u8d77&#xff0c;\u5e76\u4e14\u4f7f\u6211\u4eec\u7684\u7a0b\u5e8f\u65e0\u8bba\u62f7\u8d1d\u5230\u4efb\u4f55\u4f4d\u7f6e\u4e2d\u90fd\u80fd\u6b63\u786e\u4f7f\u7528\u56fe\u7247\u3002<\/p>\n<\/p>\n<p>Qt \u4f7f\u7528 qrc \u673a\u5236\u5e2e\u6211\u4eec\u81ea\u52a8\u5b8c\u6210\u4e86\u4e0a\u8ff0\u5de5\u4f5c&#xff0c;\u66f4\u65b9\u4fbf\u7684\u6765\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56\u7684\u9759\u6001\u8d44\u6e90\u3002<\/p>\n<p>qrc \u6587\u4ef6\u662f\u4e00\u79cd XML \u683c\u5f0f\u7684\u8d44\u6e90\u914d\u7f6e\u6587\u4ef6&#xff0c;\u5b83\u7528 XML \u8bb0\u5f55\u786c\u76d8\u4e0a\u7684\u6587\u4ef6\u548c\u5bf9\u5e94\u7684\u968f\u610f\u6307\u5b9a\u7684\u8d44\u6e90\u540d\u79f0\u3002\u5e94\u7528\u7a0b\u5e8f\u901a\u8fc7\u8d44\u6e90\u540d\u79f0\u6765\u8bbf\u95ee\u8fd9\u4e9b\u8d44\u6e90\u3002<\/p>\n<\/p>\n<p>\u5728 Qt \u5f00\u53d1\u4e2d&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u5c06\u8d44\u6e90\u6587\u4ef6\u6dfb\u52a0\u5230\u9879\u76ee\u4e2d\u6765\u65b9\u4fbf\u5730\u8bbf\u95ee\u548c\u7ba1\u7406\u8fd9\u4e9b\u8d44\u6e90\u3002<span style=\"color:#fe2c24\">\u8fd9\u4e9b\u8d44\u6e90\u6587\u4ef6\u53ef\u4ee5\u4f4d\u4e8e qrc \u6587\u4ef6\u6240\u5728\u76ee\u5f55\u7684\u540c\u7ea7\u6216\u5176\u5b50\u76ee\u5f55\u4e0b\u3002<\/span><\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u5728\u6784\u5efa\u7a0b\u5e8f\u7684\u8fc7\u7a0b\u4e2d&#xff0c;Qt \u4f1a\u628a\u8d44\u6e90\u6587\u4ef6\u7684\u4e8c\u8fdb\u5236\u6570\u636e\u8f6c\u6210 cpp \u4ee3\u7801&#xff0c;\u7f16\u8bd1\u5230 exe \u4e2d\u3002<\/span>\u4ece\u800c\u4f7f\u4f9d\u8d56\u7684\u8d44\u6e90\u53d8\u5f97\u201c\u8def\u5f84\u65e0\u5173\u201d\u3002<\/p>\n<\/p>\n<p>\u8fd9\u79cd\u8d44\u6e90\u7ba1\u7406\u673a\u5236\u5e76\u975e Qt \u72ec\u6709&#xff0c;\u5f88\u591a\u5f00\u53d1\u6846\u67b6\u90fd\u6709\u7c7b\u4f3c\u7684\u673a\u5236\u3002\u4f8b\u5982 Android \u7684 Resources \u548c AssetManager \u4e5f\u662f\u7c7b\u4f3c\u7684\u6548\u679c\u3002<\/p>\n<h4 id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E9%80%9A%E8%BF%87%20qrc%20%E7%AE%A1%E7%90%86%E5%9B%BE%E7%89%87%E4%BD%9C%E4%B8%BA%E5%9B%BE%E6%A0%87\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u901a\u8fc7 qrc \u7ba1\u7406\u56fe\u7247\u4f5c\u4e3a\u56fe\u6807<\/h4>\n<ul>\n<li>\u53f3\u952e\u9879\u76ee&#xff0c;\u521b\u5efa\u4e00\u4e2a Qt Resource File&#xff08;qrc \u6587\u4ef6&#xff09;\u6587\u4ef6\u540d\u968f\u610f\u8d77&#xff08;\u4e0d\u8981\u5e26\u4e2d\u6587&#xff09;<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"560\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011754-6ae29ec22887c.png\" width=\"878\" \/><\/p>\n<ul>\n<li>\u5728 qrc \u7f16\u8f91\u5668\u4e2d&#xff0c;\u6dfb\u52a0\u524d\u7f00\u3002<\/li>\n<li>\u6b64\u5904\u6211\u4eec\u524d\u7f00\u8bbe\u7f6e\u6210 \/ \u5373\u53ef\u3002<\/li>\n<li>\u6240\u8c13\u7684\u524d\u7f00&#xff0c;\u53ef\u4ee5\u7406\u89e3\u6210\u201c\u76ee\u5f55\u201d\u3002\u8fd9\u4e2a\u524d\u7f00\u51b3\u5b9a\u4e86\u540e\u7eed\u6211\u4eec\u5982\u4f55\u5728\u4ee3\u7801\u4e2d\u8bbf\u95ee\u8d44\u6e90\u3002<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"295\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011754-6ae29ec255dcf.png\" width=\"1030\" \/><\/p>\n<ul>\n<li>\u5728\u8d44\u6e90\u7f16\u8f91\u5668\u4e2d&#xff0c;\u70b9\u51fb add Files \u6dfb\u52a0\u8d44\u6e90\u6587\u4ef6<\/li>\n<li>\n<p><span style=\"color:#fe2c24\">\u6dfb\u52a0\u7684\u6587\u4ef6\u5fc5\u987b\u662f\u5728 qrc \u6587\u4ef6\u7684\u540c\u7ea7\u76ee\u5f55&#xff0c;\u6216\u8005\u540c\u7ea7\u76ee\u5f55\u7684\u5b50\u76ee\u5f55\u4e2d<\/span>\u3002\u56e0\u6b64\u6211\u4eec\u9700\u8981\u628a\u4e4b\u524d D \u76d8\u4e2d\u7684 rose.jpg \u590d\u5236\u5230\u4e0a\u8ff0\u76ee\u5f55\u4e2d\u3002<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"714\" src=\"2026-10-29fueq513yit0.png\" width=\"1171\" \/><\/p>\n<p>\u6dfb\u52a0\u5b8c\u6bd5\u540e&#xff0c;\u53ef\u4ee5\u5728\u8d44\u6e90\u7f16\u8f91\u5668\u4e2d\u770b\u5230\u6dfb\u52a0\u597d\u7684\u6587\u4ef6<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"162\" src=\"2026-10-29kwcrqvveqjd.png\" width=\"572\" \/><\/p>\n<p># widget.cpp<br \/>\nWidget::Widget(QWidget *parent)<br \/>\n : QWidget(parent)<br \/>\n , ui(new Ui::Widget)<br \/>\n{<br \/>\n     ui-&gt;setupUi(this);<br \/>\n     \/\/ \u8bbf\u95ee\u5230 rose.jpg \u8d44\u6e90<br \/>\n     QIcon icon(&#034;:\/rose.jpg&#034;);<br \/>\n     \/\/ \u8bbe\u7f6e\u56fe\u6807<br \/>\n     this-&gt;setWindowIcon(icon);<br \/>\n}<\/p>\n<p>\u6ce8\u610f\u4e0a\u8ff0\u8def\u5f84\u7684\u8bbf\u95ee\u89c4\u5219\u3002<\/p>\n<ul>\n<li>\u4f7f\u7528 : \u4f5c\u4e3a\u5f00\u5934&#xff0c;\u8868\u793a\u4ece qrc \u4e2d\u8bfb\u53d6\u8d44\u6e90\u3002<\/li>\n<li>\/ \u662f\u4e0a\u9762\u914d\u7f6e\u7684\u524d\u7f00\u3002<\/li>\n<li>rose.jpg \u662f\u8d44\u6e90\u7684\u540d\u79f0\u3002<\/li>\n<\/ul>\n<p><span style=\"color:#fe2c24\">\u9700\u8981\u786e\u4fdd\u4ee3\u7801\u4e2d\u7f16\u5199\u7684\u8def\u5f84\u548c\u6dfb\u52a0\u5230 qrc \u4e2d\u8d44\u6e90\u7684\u8def\u5f84\u5339\u914d\u3002\u5426\u5219\u8d44\u6e90\u65e0\u6cd5\u88ab\u8bbf\u95ee&#xff08;\u540c\u65f6\u4e5f\u4e0d\u4f1a\u6709\u62a5\u9519\u63d0\u793a&#xff09;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"644\" src=\"2026-10-29njelp32fkit.png\" width=\"806\" \/><\/p>\n<p>\u63a5\u4e0b\u6765&#xff0c;\u6211\u4eec\u53ef\u4ee5\u8fdb\u5165\u5230\u9879\u76ee\u7684\u6784\u5efa\u76ee\u5f55&#xff0c;\u53ef\u4ee5\u770b\u5230&#xff0c;\u76ee\u5f55\u4e2d\u591a\u4e86\u4e00\u4e2a qrc_resource.cpp \u6587\u4ef6\u3002\u76f4\u63a5\u6253\u5f00\u8fd9\u4e2a\u6587\u4ef6&#xff0c;\u53ef\u4ee5\u770b\u5230\u7c7b\u4f3c\u5982\u4e0b\u4ee3\u7801&#xff1a;<\/p>\n<ul>\n<li>\u5176\u5b9e\u5c31\u662f\u901a\u8fc7 unsigned char \u6570\u7ec4&#xff0c;\u628a rose.jpg \u4e2d\u7684\u6bcf\u4e2a\u5b57\u8282\u90fd\u8bb0\u5f55\u4e0b\u6765\u3002\u8fd9\u4e9b\u4ee3\u7801\u4f1a\u88ab\u7f16\u8bd1\u5230 exe \u4e2d\u3002\u540e\u7eed\u65e0\u8bba exe \u88ab\u590d\u5236\u5230\u54ea\u4e2a\u76ee\u5f55\u4e0b&#xff0c;\u90fd\u786e\u4fdd\u80fd\u591f\u8bbf\u95ee\u5230\u8be5\u56fe\u7247\u8d44\u6e90\u3002<\/li>\n<\/ul>\n<p>static const unsigned char qt_resource_data[] &#061; {<br \/>\n\/\/ D:\/project\/ke\/qt\/DemoCode\/DemoWindowIconQrc\/rose.jpg<br \/>\n 0x0,0x0,0x33,0x2,<br \/>\n 0xff,<br \/>\n 0xd8,0xff,0xe0,0x0,0x10,0x4a,0x46,0x49,0x46,0x0,0x1,0x1,0x0,0x0,0x1,0x0,<br \/>\n 0x1,0x0,0x0,0xff,0xfe,0x0,0x3b,0x43,0x52,0x45,0x41,0x54,0x4f,0x52,0x3a,0x20,<\/p>\n<p>0x67,0x64,0x2d,0x6a,0x70,0x65,0x67,0x20,0x76,0x31,0x2e,0x30,0x20,0x28,0x75,0x73<br \/>\n,<\/p>\n<p>0x69,0x6e,0x67,0x20,0x49,0x4a,0x47,0x20,0x4a,0x50,0x45,0x47,0x20,0x76,0x36,0x32<br \/>\n,<\/p>\n<p>0x29,0x2c,0x20,0x71,0x75,0x61,0x6c,0x69,0x74,0x79,0x20,0x3d,0x20,0x39,0x35,0xa,<br \/>\n 0xff,0xdb,0x0,0x43,0x0,0x2,0x1,0x1,0x1,0x1,0x1,0x2,0x1,0x1,0x1,0x2,<br \/>\n 0x2,0x2,0x2,0x2,0x4,0x3,0x2,0x2,0x2,0x2,0x5,0x4,0x4,0x3,0x4,0x6,<br \/>\n 0x5,0x6,0x6,0x6,0x5,0x6,0x6,0x6,0x7,0x9,0x8,0x6,0x7,0x9,0x7,0x6,<br \/>\n 0x6,0x8,0xb,0x8,0x9,0xa,0xa,0xa,0xa,0xa,0x6,0x8,0xb,0xc,0xb,0xa,<br \/>\n 0xc,0x9,0xa,0xa,0xa,0xff,0xdb,0x0,0x43,0x1,0x2,0x2,0x2,0x2,0x2,0x2,<br \/>\n \/\/ &#8230;&#8230;&#8230;&#8230;.<\/p>\n<p>\u4e0a\u8ff0 qrc \u8fd9\u4e00\u5957\u8d44\u6e90\u7ba1\u7406\u65b9\u6848&#xff0c;\u4f18\u70b9\u548c\u7f3a\u70b9\u90fd\u5f88\u660e\u663e\u3002<\/p>\n<\/p>\n<p>\u4f18\u70b9&#xff1a;\u786e\u4fdd\u4e86\u56fe\u7247&#xff0c;\u5b57\u4f53&#xff0c;\u58f0\u97f3\u7b49\u8d44\u6e90\u80fd\u591f\u771f\u6b63\u505a\u5230\u201c\u76ee\u5f55\u65e0\u5173\u201d&#xff0c;\u65e0\u8bba\u5982\u4f55\u90fd\u4e0d\u4f1a\u51fa\u73b0\u8d44\u6e90\u4e22\u5931\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p>\u7f3a\u70b9&#xff1a;<span style=\"color:#fe2c24\">\u4e0d\u9002\u5408\u7ba1\u7406\u4f53\u79ef\u5927\u7684\u8d44\u6e90<\/span>\u3002\u5982\u679c\u8d44\u6e90\u6bd4\u8f83\u5927&#xff08;\u6bd4\u5982\u662f\u51e0\u4e2a MB \u7684\u6587\u4ef6&#xff09;&#xff0c;\u6216\u8005\u8d44\u6e90\u7279\u522b\u591a&#xff0c;\u751f\u6210\u7684\u6700\u7ec8\u7684 exe \u4f53\u79ef\u5c31\u4f1a\u6bd4\u8f83\u5927&#xff0c;\u7a0b\u5e8f\u8fd0\u884c\u6d88\u8017\u7684\u5185\u5b58\u4e5f\u4f1a\u589e\u5927&#xff0c;\u7a0b\u5e8f\u7f16\u8bd1\u7684\u65f6\u95f4\u4e5f\u4f1a\u663e\u8457\u589e\u52a0\u3002<\/p>\n<h3 id=\"2.6%20windowOpacity%EF%BC%88%E6%8E%A7%E4%BB%B6%E9%80%8F%E6%98%8E%E5%BA%A6%EF%BC%89\" style=\"background-color:transparent\">2.6 windowOpacity&#xff08;\u63a7\u4ef6\u900f\u660e\u5ea6&#xff09;<\/h3>\n<table>\n<tr>API\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#fe2c24\">windowOpacity()<\/span><\/td>\n<td>\u83b7\u53d6\u5230\u63a7\u4ef6\u7684\u4e0d\u900f\u660e\u6570\u503c&#xff0c;\u8fd4\u56de float&#xff0c;\u53d6\u503c\u4e3a 0.0 -&gt; 1.0&#xff0c;\u5176\u4e2d 0.0 \u8868\u793a\u5168\u900f\u660e&#xff0c;1.0 \u8868\u793a\u5b8c\u5168\u4e0d\u900f\u660e\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">setWindowOpacity(float n)<\/span><\/td>\n<td>\u8bbe\u7f6e\u63a7\u4ef6\u7684\u4e0d\u900f\u660e\u6570\u503c\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E8%B0%83%E6%95%B4%E7%AA%97%E5%8F%A3%E9%80%8F%E6%98%8E%E5%BA%A6\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u8c03\u6574\u7a97\u53e3\u900f\u660e\u5ea6<\/h4>\n<p>\u5728\u754c\u9762\u4e0a\u62d6\u653e\u4e24\u4e2a\u6309\u94ae&#xff0c;\u5206\u522b\u7528\u6765\u589e\u52a0\u4e0d\u900f\u660e\u5ea6\u548c\u51cf\u5c11\u4e0d\u900f\u660e\u5ea6\u3002objectName \u5206\u522b\u4e3a<\/p>\n<ul>\n<li>pushButton_add<\/li>\n<li>pushButton_sub<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"608\" src=\"2026-10-29radkkxqx42h.png\" width=\"802\" \/><\/p>\n<p># widget.cpp \u4e2d\u7f16\u5199\u69fd\u51fd\u6570<br \/>\nvoid Widget::on_pushButton_add_clicked()<br \/>\n{<br \/>\n     float opacity &#061; this-&gt;windowOpacity();<br \/>\n     if (opacity &gt;&#061; 1.0) {<br \/>\n     return;<br \/>\n     }<br \/>\n     qDebug() &lt;&lt; opacity;<br \/>\n     opacity &#043;&#061; 0.1;<br \/>\n     this-&gt;setWindowOpacity(opacity);<br \/>\n}<\/p>\n<p>void Widget::on_pushButton_sub_clicked()<br \/>\n{<br \/>\n     float opacity &#061; this-&gt;windowOpacity();<br \/>\n    if (opacity &lt;&#061; 0.0) {<br \/>\n     return;<br \/>\n     }<br \/>\n     qDebug() &lt;&lt; opacity;<br \/>\n     opacity -&#061; 0.1;<br \/>\n     this-&gt;setWindowOpacity(opacity);<br \/>\n}<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"645\" src=\"2026-10-29y0bxmigbp42.png\" width=\"806\" \/><\/p>\n<p>\u540c\u65f6\u63a7\u5236\u53f0\u4e2d\u4e5f\u53ef\u4ee5\u770b\u5230 opacity \u6570\u503c\u7684\u53d8\u5316\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a;C&#043;&#043; \u4e2d float \u7c7b\u578b\u9075\u5b88 IEEE 754 \u6807\u51c6&#xff0c;\u56e0\u6b64\u5728\u8fdb\u884c\u8fd0\u7b97\u7684\u65f6\u5019\u4f1a\u6709\u4e00\u5b9a\u7684\u7cbe\u5ea6\u8bef\u5dee&#xff0c;\u56e0\u6b64 1 &#8211; 0.1 \u7684\u6570\u503c\u5e76\u975e\u662f 0.9\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"361\" src=\"2026-10-29beexnrrs1zq.png\" width=\"188\" \/><\/p>\n<h3 id=\"2.7%20cursor%EF%BC%88%E9%BC%A0%E6%A0%87%EF%BC%89\" style=\"background-color:transparent\">2.7 cursor&#xff08;\u9f20\u6807&#xff09;<\/h3>\n<table>\n<tr>API\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#fe2c24\">cursor()<\/span><\/td>\n<td>\u83b7\u53d6\u5230\u5f53\u524d widget \u7684 cursor \u5c5e\u6027&#xff0c;\u8fd4\u56de QCursor \u5bf9\u8c61\u3002\u5f53\u9f20\u6807\u60ac\u505c\u5728\u8be5 widget \u4e0a\u65f6&#xff0c;\u5c31\u4f1a\u663e\u793a\u51fa\u5bf9\u5e94\u7684\u5f62\u72b6\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">setCursor(const QCursor&amp; cursor)<\/span><\/td>\n<td>\u8bbe\u7f6e\u8be5 widget \u5149\u6807\u7684\u5f62\u72b6\u3002\u4ec5\u5728\u9f20\u6807\u505c\u7559\u5728\u8be5 widget \u4e0a\u65f6\u751f\u6548\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">QGuiApplication::setOverrideCursor(const QCursor&amp; cursor)<\/span><\/td>\n<td>\u8bbe\u7f6e\u5168\u5c40\u5149\u6807\u7684\u5f62\u72b6\u3002\u5bf9\u6574\u4e2a\u7a0b\u5e8f\u4e2d\u7684\u6240\u6709 widget \u90fd\u4f1a\u751f\u6548&#xff0c;\u8986\u76d6\u4e0a\u9762\u7684 setCursor \u8bbe\u7f6e\u7684\u5185\u5bb9\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E5%9C%A8%20Qt%20Designer%20%E4%B8%AD%E8%AE%BE%E7%BD%AE%E6%8C%89%E9%92%AE%E7%9A%84%E5%85%89%E6%A0%87\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u5728 Qt Designer \u4e2d\u8bbe\u7f6e\u6309\u94ae\u7684\u5149\u6807<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"452\" src=\"2026-10-29keknwovfb5k.png\" width=\"645\" \/><\/p>\n<p>\u76f4\u63a5\u5728\u53f3\u4fa7\u5c5e\u6027\u7f16\u8f91\u533a\u4fee\u6539 cursor \u5c5e\u6027\u4e3a\u201c\u7b49\u5f85\u201d\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"31\" src=\"2026-10-294i2k54b5cre.png\" width=\"528\" \/><\/p>\n<h4 id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E9%80%9A%E8%BF%87%E4%BB%A3%E7%A0%81%E8%AE%BE%E7%BD%AE%E6%8C%89%E9%92%AE%E7%9A%84%E5%85%89%E6%A0%87\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u901a\u8fc7\u4ee3\u7801\u8bbe\u7f6e\u6309\u94ae\u7684\u5149\u6807<\/h4>\n<ul>\n<li>Qt::WaitCursor \u5c31\u662f\u81ea\u5e26\u7684\u6c99\u6f0f\u5f62\u72b6\u7684\u5149\u6807\u3002<\/li>\n<\/ul>\n<p>#include &lt;QPushButton&gt;<br \/>\nWidget::Widget(QWidget *parent)<br \/>\n : QWidget(parent)<br \/>\n , ui(new Ui::Widget)<br \/>\n{<br \/>\n     ui-&gt;setupUi(this);<br \/>\n     \/\/ \u521b\u5efa\u6309\u94ae<br \/>\n     QPushButton* button &#061; new QPushButton(this);<br \/>\n     button-&gt;resize(100, 50);<br \/>\n     button-&gt;move(100, 100);<br \/>\n     button-&gt;setText(&#034;\u8fd9\u662f\u2f00\u4e2a\u6309\u94ae&#034;);<br \/>\n     \/\/ \u8bbe\u7f6e\u6309\u94ae\u7684 cursor<br \/>\n     button-&gt;setCursor(QCursor(Qt::WaitCursor));<br \/>\n}<\/p>\n<p>\u7cfb\u7edf\u5185\u7f6e\u7684\u5149\u6807\u5f62\u72b6\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>Ctrl &#043; \u5de6\u952e\u70b9\u51fb Qt::WaitCursor \u8df3\u8f6c\u5230\u6e90\u7801\u5373\u53ef\u770b\u5230\u3002<\/li>\n<\/ul>\n<p>enum CursorShape {<br \/>\n ArrowCursor,<br \/>\n UpArrowCursor,<br \/>\n CrossCursor,<br \/>\n WaitCursor,<br \/>\n IBeamCursor,<br \/>\n SizeVerCursor,<br \/>\n SizeHorCursor,<br \/>\n SizeBDiagCursor,<br \/>\n SizeFDiagCursor,<br \/>\n SizeAllCursor,<br \/>\n BlankCursor,<br \/>\n SplitVCursor,<br \/>\n SplitHCursor,<br \/>\n PointingHandCursor,<br \/>\n ForbiddenCursor,<br \/>\n WhatsThisCursor,<br \/>\n BusyCursor,<br \/>\n OpenHandCursor,<br \/>\n ClosedHandCursor,<br \/>\n DragCopyCursor,<br \/>\n DragMoveCursor,<br \/>\n DragLinkCursor,<br \/>\n LastCursor &#061; DragLinkCursor,<br \/>\n BitmapCursor &#061; 24,<br \/>\n CustomCursor &#061; 25<br \/>\n }<\/p>\n<h4 id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E8%87%AA%E5%AE%9A%E4%B9%89%E9%BC%A0%E6%A0%87%E5%9B%BE%E6%A0%87\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u81ea\u5b9a\u4e49\u9f20\u6807\u56fe\u6807<\/h4>\n<p>Qt \u81ea\u5e26\u7684\u5149\u6807\u5f62\u72b6\u6709\u9650\u3002\u6211\u4eec\u4e5f\u53ef\u4ee5\u81ea\u5df1\u627e\u4e2a\u56fe\u7247&#xff0c;\u505a\u6210\u9f20\u6807\u7684\u5149\u6807\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"100\" src=\"2026-10-29u5sw20fbztq.png\" width=\"100\" \/><\/p>\n<p>\u521b\u5efa qrc \u8d44\u6e90\u6587\u4ef6&#xff0c;\u6dfb\u52a0\u524d\u7f00 \/&#xff0c;\u5e76\u52a0\u5165 huaji.png\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"101\" src=\"2026-10-29c0gbqitiaqr.png\" width=\"398\" \/><\/p>\n<p>#include &lt;QPixmap&gt;<br \/>\nWidget::Widget(QWidget *parent)<br \/>\n : QWidget(parent)<br \/>\n , ui(new Ui::Widget)<br \/>\n{<br \/>\n     ui-&gt;setupUi(this);<br \/>\n     \/\/ \u521b\u5efa\u2f00\u4e2a\u4f4d\u56fe\u5bf9\u8c61, \u52a0\u8f7d\u2f83\u5b9a\u4e49\u5149\u6807\u56fe\u2f5a<br \/>\n     QPixmap pixmap(&#034;:\/huaji.png&#034;);<br \/>\n     \/\/ \u7f29\u653e\u56fe\u2f5a\u4e3a 64 * 64 \u7684\u5c3a\u2f28.<br \/>\n     pixmap &#061; pixmap.scaled(64, 64);<br \/>\n     \/\/ \u521b\u5efa QCursor \u5bf9\u8c61, \u5e76\u6307\u5b9a &#034;\u70ed\u70b9&#034; \u4e3a (2, 2) \u5750\u6807\u4f4d\u7f6e.<br \/>\n     \/\/ \u6240\u8c13 &#034;\u70ed\u70b9&#034; \u5c31\u662f\u2fcf\u6807\u70b9\u51fb\u65f6\u2f63\u6548\u7684\u4f4d\u7f6e.<br \/>\n     QCursor cursor(pixmap, 2, 2);<br \/>\n     \/\/ \u8bbe\u7f6e\u5149\u6807<br \/>\n     this-&gt;setCursor(cursor);<br \/>\n}<\/p>\n<h3 id=\"2.8%20font%EF%BC%88%E5%AD%97%E4%BD%93%EF%BC%89\">2.8 font&#xff08;\u5b57\u4f53&#xff09;<\/h3>\n<table>\n<tr>API\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#fe2c24\">font()<\/span><\/td>\n<td>\u83b7\u53d6\u5f53\u524d widget \u7684\u5b57\u4f53\u4fe1\u606f&#xff0c;\u8fd4\u56de QFont \u5bf9\u8c61\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">setFont(const QFont&amp; font)<\/span><\/td>\n<td>\u8bbe\u7f6e\u5f53\u524d widget \u7684\u5b57\u4f53\u4fe1\u606f\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table>\n<tr>\u5c5e\u6027\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#fe2c24\">family<\/span><\/td>\n<td>\u5b57\u4f53\u5bb6\u65cf\u3002\u6bd4\u5982\u201c\u6977\u4f53\u201d\u201c\u5b8b\u4f53\u201d\u201c\u5fae\u8f6f\u96c5\u9ed1\u201d\u7b49\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">pointSize<\/span><\/td>\n<td>\u5b57\u4f53\u5927\u5c0f\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">weight<\/span><\/td>\n<td>\u5b57\u4f53\u7c97\u7ec6\u3002\u4ee5\u6570\u503c\u65b9\u5f0f\u8868\u793a\u7c97\u7ec6\u7a0b\u5ea6&#xff0c;\u53d6\u503c\u8303\u56f4\u4e3a [0, 99]&#xff0c;\u6570\u503c\u8d8a\u5927&#xff0c;\u8d8a\u7c97\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">bold<\/span><\/td>\n<td>\u662f\u5426\u52a0\u7c97\u3002\u8bbe\u7f6e\u4e3a true&#xff0c;\u76f8\u5f53\u4e8e weight \u4e3a 75&#xff1b;\u8bbe\u7f6e\u4e3a false&#xff0c;\u76f8\u5f53\u4e8e weight \u4e3a 50\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">italic<\/span><\/td>\n<td>\u662f\u5426\u503e\u659c\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">underline<\/span><\/td>\n<td>\u662f\u5426\u5e26\u6709\u4e0b\u5212\u7ebf\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">strikeOut<\/span><\/td>\n<td>\u662f\u5426\u5e26\u6709\u5220\u9664\u7ebf\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"%E7%A4%BA%E4%BE%8B%EF%BC%9A%E5%9C%A8%20Qt%20Designer%20%E4%B8%AD%E8%AE%BE%E7%BD%AE%E5%AD%97%E4%BD%93%E5%B1%9E%E6%80%A7\">\u793a\u4f8b&#xff1a;\u5728 Qt Designer \u4e2d\u8bbe\u7f6e\u5b57\u4f53\u5c5e\u6027<\/h4>\n<p>\u5728\u53f3\u4fa7\u7684\u5c5e\u6027\u7f16\u8f91\u533a&#xff0c;\u8bbe\u7f6e label \u7684 font \u76f8\u5173\u5c5e\u6027\u3002\u5728\u8fd9\u91cc\u8c03\u6574\u4e0a\u8ff0\u5c5e\u6027&#xff0c;\u53ef\u4ee5\u5b9e\u65f6\u7684\u770b\u5230\u6587\u5b57\u7684\u53d8\u5316\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"221\" src=\"2026-10-29wkid3bjxq0l.png\" width=\"526\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"634\" src=\"2026-10-29rm5qdwcpji4.png\" width=\"795\" \/><\/p>\n<h4 id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E5%9C%A8%E4%BB%A3%E7%A0%81%E4%B8%AD%E8%AE%BE%E7%BD%AE%E5%AD%97%E4%BD%93%E5%B1%9E%E6%80%A7%E3%80%82\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u5728\u4ee3\u7801\u4e2d\u8bbe\u7f6e\u5b57\u4f53\u5c5e\u6027\u3002<\/h4>\n<p>Widget::Widget(QWidget *parent)<br \/>\n : QWidget(parent)<br \/>\n , ui(new Ui::Widget)<br \/>\n{<br \/>\n     ui-&gt;setupUi(this);<br \/>\n     \/\/ \u8bbe\u7f6e label \u7684\u2f42\u672c\u5185\u5bb9<br \/>\n     ui-&gt;label-&gt;setText(&#034;\u8fd9\u662f\u2f00\u6bb5\u2f42\u672c&#034;);<\/p>\n<p>     \/\/ \u521b\u5efa\u5b57\u4f53\u5bf9\u8c61<br \/>\n     QFont font;<br \/>\n     \/\/ \u8bbe\u7f6e\u5b57\u4f53\u5bb6\u65cf<br \/>\n     font.setFamily(&#034;\u4eff\u5b8b&#034;);<br \/>\n     \/\/ \u8bbe\u7f6e\u5b57\u4f53\u2f24\u2f29<br \/>\n     font.setPointSize(20);<br \/>\n     \/\/ \u8bbe\u7f6e\u5b57\u4f53\u52a0\u7c97<br \/>\n     font.setBold(true);<br \/>\n     \/\/ \u8bbe\u7f6e\u5b57\u4f53\u503e\u659c<br \/>\n     font.setItalic(true);<br \/>\n     \/\/ \u8bbe\u7f6e\u5b57\u4f53\u4e0b\u5212\u7ebf<br \/>\n     font.setUnderline(true);<br \/>\n     \/\/ \u8bbe\u7f6e\u5b57\u4f53\u5220\u9664\u7ebf<br \/>\n     font.setStrikeOut(true);<br \/>\n     \/\/ \u8bbe\u7f6e\u5b57\u4f53\u5bf9\u8c61\u5230 label \u4e0a<br \/>\n     ui-&gt;label-&gt;setFont(font);<br \/>\n}<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"633\" src=\"2026-10-29sl4a1jp0sw3.png\" width=\"799\" \/><\/p>\n<p>\u5b9e\u9645\u5f00\u53d1\u4e2d&#xff0c;\u5b57\u4f53\u5c5e\u6027\u5982\u4f55\u9009\u62e9&#xff0c;\u662f\u4e00\u4e2a\u201c\u5ba1\u7f8e\u95ee\u9898\u201d&#xff0c;\u800c\u4e0d\u662f\u201c\u6280\u672f\u95ee\u9898\u201d\u3002\u5f80\u5f80\u9700\u8981\u6709\u4e00\u5b9a\u7684\u827a\u672f\u7ec6\u80de\u3002\u5e78\u8fd0\u7684\u662f&#xff0c;\u516c\u53f8\u4e2d\u5f80\u5f80\u6709\u4e13\u4e1a\u7684\u201c\u7f8e\u5de5\u201d\/\u201c\u8bbe\u8ba1\u201d\u8fd9\u6837\u7684\u5c97\u4f4d&#xff0c;\u53bb\u505a\u8fd9\u65b9\u9762\u7684\u5de5\u4f5c\u3002\u54b1\u4eec\u7a0b\u5e8f\u5458\u53ea\u8981\u6309\u7167\u4eba\u5bb6\u7ed9\u7684\u8bbe\u8ba1\u7a3f&#xff0c;\u628a\u4ee3\u7801\u5199\u51fa\u6765\u5373\u53ef\u3002\u4e0d\u5fc5\u8fc7\u591a\u8003\u8651\u600e\u6837\u642d\u914d\u624d\u597d\u770b\u7684\u95ee\u9898\u3002<\/p>\n<h3 id=\"2.9%20toolTip%EF%BC%88%E9%BC%A0%E6%A0%87%E6%82%AC%E5%81%9C%E6%8F%90%E7%A4%BA%EF%BC%89\">2.9 toolTip&#xff08;\u9f20\u6807\u60ac\u505c\u63d0\u793a&#xff09;<\/h3>\n<p>toolTip \u53ea\u662f\u7ed9\u7528\u6237\u770b\u7684\u3002\u5728\u4ee3\u7801\u4e2d\u4e00\u822c\u4e0d\u9700\u8981\u83b7\u53d6\u5230 toolTip\u3002<\/p>\n<table>\n<tr>API\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#fe2c24\">setToolTip<\/span><\/td>\n<td>\u8bbe\u7f6e toolTip\u3002\u9f20\u6807\u60ac\u505c\u5728\u8be5 widget \u4e0a\u65f6\u4f1a\u6709\u63d0\u793a\u8bf4\u660e\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">setToolTipDuring<\/span><\/td>\n<td>\u8bbe\u7f6e toolTip \u63d0\u793a\u7684\u65f6\u95f4\u3002\u5355\u4f4d ms\u3002\u65f6\u95f4\u5230\u540e toolTip \u81ea\u52a8\u6d88\u5931\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E8%AE%BE%E7%BD%AE%E6%8C%89%E9%92%AE%E7%9A%84%20toolTip\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u8bbe\u7f6e\u6309\u94ae\u7684 toolTip<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"551\" src=\"2026-10-29dmqhqtuf4uy.png\" width=\"795\" \/><\/p>\n<p>Widget::Widget(QWidget *parent)<br \/>\n : QWidget(parent)<br \/>\n , ui(new Ui::Widget)<br \/>\n{<br \/>\n     ui-&gt;setupUi(this);<br \/>\n     ui-&gt;pushButton_yes-&gt;setToolTip(&#034;\u8fd9\u4e2a\u662f yes \u6309\u94ae&#034;);<br \/>\n     ui-&gt;pushButton_yes-&gt;setToolTipDuration(3000);<br \/>\n     ui-&gt;pushButton_no-&gt;setToolTip(&#034;\u8fd9\u4e2a\u662f no \u6309\u94ae&#034;);<br \/>\n     ui-&gt;pushButton_no-&gt;setToolTipDuration(10000);<br \/>\n}<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"631\" src=\"2026-10-29obzssykrgkq.png\" width=\"791\" \/><\/p>\n<h3 id=\"2.10%20focusPolicy%EF%BC%88%E7%84%A6%E7%82%B9%EF%BC%89\" style=\"background-color:transparent\">2.10 focusPolicy&#xff08;\u7126\u70b9&#xff09;<\/h3>\n<p>\u8bbe\u7f6e\u63a7\u4ef6\u83b7\u53d6\u5230\u7126\u70b9\u7684\u7b56\u7565\u3002\u6bd4\u5982\u67d0\u4e2a\u63a7\u4ef6\u80fd\u5426\u7528\u9f20\u6807\u9009\u4e2d\u6216\u8005\u80fd\u5426\u901a\u8fc7 tab \u952e\u9009\u4e2d\u3002<\/p>\n<p>\u6240\u8c13\u201c\u7126\u70b9\u201d&#xff0c;\u6307\u7684\u5c31\u662f\u80fd\u9009\u4e2d\u8fd9\u4e2a\u5143\u7d20\u3002\u63a5\u4e0b\u6765\u7684\u64cd\u4f5c&#xff08;\u6bd4\u5982\u952e\u76d8\u64cd\u4f5c&#xff09;&#xff0c;\u5c31\u90fd\u662f\u9488\u5bf9\u8be5\u7126\u70b9\u5143\u7d20\u8fdb\u884c\u7684\u4e86\u3002\u8fd9\u4e2a\u5bf9\u4e8e\u8f93\u5165\u6846&#xff0c;\u5355\u9009\u6846&#xff0c;\u590d\u9009\u6846\u7b49\u63a7\u4ef6\u975e\u5e38\u6709\u7528\u7684\u3002<\/p>\n<p>\u8fd9\u4e2a\u4e8b\u60c5\u5c31\u548c LOL \u4e2d&#xff0c;\u5148\u9009\u4e2d\u5355\u4f4d&#xff0c;\u518d\u4e0b\u8fbe\u547d\u4ee4\u662f\u4e00\u6837\u7684\u3002<\/p>\n<table>\n<tr>API\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#fe2c24\">focusPolicy()<\/span><\/td>\n<td>\u83b7\u53d6\u8be5 widget \u7684 focusPolicy&#xff0c;\u8fd4\u56de Qt::FocusPolicy\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">setFocusPolicy(Qt::FocusPolicy policy)<\/span><\/td>\n<td>\u8bbe\u7f6e widget \u7684 focusPolicy\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Qt::FocusPolicy \u662f\u4e00\u4e2a\u679a\u4e3e\u7c7b\u578b\u3002\u53d6\u503c\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>Qt::NoFocus&#xff1a;\u63a7\u4ef6\u4e0d\u4f1a\u63a5\u6536\u952e\u76d8\u7126\u70b9\u3002<\/li>\n<li>Qt::TabFocus&#xff1a;\u63a7\u4ef6\u53ef\u4ee5\u901a\u8fc7 Tab \u952e\u63a5\u6536\u7126\u70b9\u3002<\/li>\n<li>Qt::ClickFocus&#xff1a;\u63a7\u4ef6\u5728\u9f20\u6807\u70b9\u51fb\u65f6\u63a5\u6536\u7126\u70b9\u3002<\/li>\n<li>Qt::StrongFocus&#xff1a;\u63a7\u4ef6\u53ef\u4ee5\u901a\u8fc7 Tab \u952e\u548c\u9f20\u6807\u70b9\u51fb\u63a5\u6536\u7126\u70b9&#xff08;\u9ed8\u8ba4\u503c&#xff09;\u3002<\/li>\n<li>Qt::WheelFocus&#xff1a;\u7c7b\u4f3c\u4e8e Qt::StrongFocus&#xff0c;\u540c\u65f6\u63a7\u4ef6\u4e5f\u901a\u8fc7\u9f20\u6807\u6eda\u8f6e\u83b7\u53d6\u5230\u7126\u70b9&#xff08;\u65b0\u589e\u7684\u9009\u9879&#xff0c;\u4e00\u822c\u5f88\u5c11\u4f7f\u7528&#xff09;\u3002<\/li>\n<\/ul>\n<h4 id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E7%90%86%E8%A7%A3%E4%B8%8D%E5%90%8C%E7%9A%84%20focusPolicy\">\u4ee3\u7801\u793a\u4f8b&#xff1a;\u7406\u89e3\u4e0d\u540c\u7684 focusPolicy<\/h4>\n<ul>\n<li>\u5728\u754c\u9762\u4e0a\u521b\u5efa\u56db\u4e2a\u5355\u884c\u8f93\u5165\u6846&#xff08;Line Edit&#xff09;<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"603\" src=\"2026-10-29weknz04ltxp.png\" width=\"805\" \/><\/p>\n<p>\u4fee\u6539\u56db\u4e2a\u8f93\u5165\u6846\u7684 focusPolicy \u5c5e\u6027\u4e3a Qt::StrongFocus&#xff08;\u9ed8\u8ba4\u53d6\u503c&#xff0c;\u4e00\u822c\u4e0d\u7528\u989d\u5916\u4fee\u6539&#xff09;\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"31\" src=\"2026-10-29ygh5rblwzzt.png\" width=\"512\" \/><\/p>\n<p>\u6b64\u65f6\u8fd0\u884c\u7a0b\u5e8f&#xff0c;\u53ef\u4ee5\u770b\u5230&#xff0c;\u4f7f\u7528\u9f20\u6807\u5355\u51fb\/tab&#xff0c;\u5c31\u53ef\u4ee5\u79fb\u52a8\u5149\u6807\u6240\u5728\u8f93\u5165\u6846\u3002\u4ece\u800c\u63a5\u4e0b\u6765\u7684\u8f93\u5165\u5c31\u662f\u9488\u5bf9\u8fd9\u4e2a\u83b7\u53d6\u7126\u70b9\u7684\u8f93\u5165\u6846\u5c55\u5f00\u7684\u4e86\u3002<\/p>\n<ul>\n<li>\u4fee\u6539\u7b2c\u4e8c\u4e2a\u8f93\u5165\u6846\u7684 focusPolicy \u4e3a Qt::NoFocus&#xff0c;\u5219\u7b2c\u4e8c\u4e2a\u8f93\u5165\u6846\u4e0d\u4f1a\u88ab tab \/ \u9f20\u6807\u5de6\u952e\u9009\u4e2d\u3002\u6b64\u65f6\u8fd9\u4e2a\u8f93\u5165\u6846\u4e5f\u5c31\u65e0\u6cd5\u8f93\u5165\u5185\u5bb9\u4e86\u3002<\/li>\n<li>\u4fee\u6539\u7b2c\u4e8c\u4e2a\u8f93\u5165\u6846 focusPolicy \u4e3a Qt::TabFocus&#xff0c;\u5219\u53ea\u80fd\u901a\u8fc7 tab \u9009\u4e2d&#xff0c;\u65e0\u6cd5\u901a\u8fc7\u9f20\u6807\u9009\u4e2d\u3002<\/li>\n<li>\u4fee\u6539\u7b2c\u4e8c\u4e2a\u8f93\u5165\u6846 focusPolicy \u4e3a Qt::ClickFocus&#xff0c;\u5219\u53ea\u80fd\u901a\u8fc7\u9f20\u6807\u9009\u4e2d&#xff0c;\u65e0\u6cd5\u901a\u8fc7 tab \u9009\u4e2d\u3002<\/li>\n<\/ul>\n<h3 id=\"2.11%20styleSheet%EF%BC%88widget%E6%A0%B7%E5%BC%8F%EF%BC%89\">2.11 styleSheet&#xff08;widget\u6837\u5f0f&#xff09;<\/h3>\n<p>\u901a\u8fc7 CSS \u8bbe\u7f6e widget \u7684\u6837\u5f0f\u3002<\/p>\n<p>CSS (Cascading Style Sheets \u5c42\u53e0\u6837\u5f0f\u8868) \u672c\u8eab\u5c5e\u4e8e\u7f51\u9875\u524d\u7aef\u6280\u672f\u3002\u4e3b\u8981\u5c31\u662f\u7528\u6765\u63cf\u8ff0\u754c\u9762\u7684 \u6837\u5f0f\u3002<\/p>\n<\/p>\n<p>\u6240\u8c13 &#034;\u6837\u5f0f&#034;&#xff0c;\u5305\u62ec\u4e0d\u9650\u4e8e \u5927\u5c0f&#xff0c;\u4f4d\u7f6e&#xff0c;\u989c\u8272&#xff0c;\u95f4\u8ddd&#xff0c;\u5b57\u4f53&#xff0c;\u80cc\u666f&#xff0c;\u8fb9\u6846\u7b49\u3002<\/p>\n<p>\u6211\u4eec\u5e73\u65f6\u770b\u5230\u7684\u4e30\u5bcc\u591a\u5f69\u7684\u7f51\u9875&#xff0c;\u5c31\u90fd\u4f1a\u7528\u5230\u5927\u91cf\u7684 CSS\u3002<\/p>\n<\/p>\n<p>Qt \u867d\u7136\u662f\u505a GUI \u5f00\u53d1&#xff0c;\u4f46\u5b9e\u9645\u4e0a\u548c \u7f51\u9875\u524d\u7aef \u6709\u5f88\u591a\u5f02\u66f2\u540c\u5de5\u4e4b\u5904\u3002\u56e0\u6b64 Qt \u4e5f\u5f15\u5165\u4e86\u5bf9\u4e8e CSS \u7684\u652f\u6301\u3002<\/p>\n<p>CSS \u4e2d\u53ef\u4ee5\u8bbe\u7f6e\u7684\u6837\u5f0f\u5c5e\u6027\u975e\u5e38\u591a\u3002\u57fa\u4e8e\u8fd9\u4e9b\u5c5e\u6027 Qt \u53ea\u80fd\u652f\u6301\u5176\u4e2d\u4e00\u90e8\u5206&#xff0c;\u79f0\u4e3a QSS (Qt Style Sheet)\u3002\u5177\u4f53\u7684\u652f\u6301\u60c5\u51b5\u53ef\u4ee5\u53c2\u8003 Qt \u6587\u6863\u4e2d &#034;Qt Style Sheets Reference&#034; \u7ae0\u8282\u3002<\/p>\n<h4 id=\"%E7%A4%BA%E4%BE%8B%3A%20%E8%AE%BE%E7%BD%AE%E6%96%87%E6%9C%AC%E6%A0%B7%E5%BC%8F\">\u793a\u4f8b: \u8bbe\u7f6e\u6587\u672c\u6837\u5f0f<\/h4>\n<ul>\n<li>\u521b\u5efa\u4e00\u4e2a label \u63a7\u4ef6<\/li>\n<li>\u7f16\u8f91\u53f3\u4fa7\u7684 styleSheet \u5c5e\u6027&#xff0c;\u8bbe\u7f6e\u6837\u5f0f<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"319\" src=\"2026-10-29ry5zfyf1b2p.png\" width=\"424\" \/><\/p>\n<p>\u6b64\u5904\u7684\u8bed\u6cd5\u683c\u5f0f\u540c CSS&#xff0c;\u4f7f\u7528\u952e\u503c\u5bf9\u7684\u65b9\u5f0f\u8bbe\u7f6e\u6837\u5f0f\u3002\u5176\u4e2d\u952e\u548c\u503c\u4e4b\u95f4\u4f7f\u7528 : \u5206\u5272\u3002\u952e\u503c\u5bf9\u4e4b\u95f4\u4f7f\u7528 ; \u5206\u5272\u3002<\/p>\n<\/p>\n<p>\u53e6\u5916&#xff0c;Qt Designer \u53ea\u80fd\u5bf9\u6837\u5f0f\u7684\u57fa\u672c\u683c\u5f0f\u8fdb\u884c\u6821\u9a8c&#xff0c;\u4e0d\u80fd\u68c0\u6d4b\u51fa\u54ea\u4e9b\u6837\u5f0f\u4e0d\u88ab Qt \u652f\u6301\u3002\u6bd4\u5982 textalign: center \u8fd9\u6837\u7684\u6587\u672c\u5c45\u4e2d\u64cd\u4f5c&#xff0c;\u5c31\u65e0\u6cd5\u652f\u6301\u3002<\/p>\n<p>\u7f16\u8f91\u5b8c\u6210\u6837\u5f0f\u4e4b\u540e&#xff0c;\u53ef\u4ee5\u770b\u5230\u5728 Qt Designer \u4e2d\u80fd\u591f\u5b9e\u65f6\u9884\u89c8\u51fa\u6548\u679c<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"598\" src=\"2026-10-29vrcuosybdbw.png\" width=\"801\" \/><\/p>\n<h4 id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%3A%20%E5%AE%9E%E7%8E%B0%E5%88%87%E6%8D%A2%E5%A4%9C%E9%97%B4%E6%A8%A1%E5%BC%8F%E3%80%82\">\u4ee3\u7801\u793a\u4f8b: \u5b9e\u73b0\u5207\u6362\u591c\u95f4\u6a21\u5f0f\u3002<\/h4>\n<ul>\n<li>\u5728\u754c\u9762\u4e0a\u521b\u5efa\u4e00\u4e2a\u591a\u884c\u8f93\u5165\u6846 (Text Edit) \u548c\u4e24\u4e2a\u6309\u94ae\u3002<\/li>\n<li>objectName \u5206\u522b\u4e3a pushButton_light \u548c pushButton_dark<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"598\" src=\"2026-10-29ufyr13xc3jl.png\" width=\"799\" \/><\/p>\n<p>\u7f16\u5199\u6309\u94ae\u7684 slot \u51fd\u6570\u3002<\/p>\n<ul>\n<li>#333 \u662f\u6df1\u8272&#xff0c;\u4f46\u662f\u6ca1\u90a3\u4e48\u9ed1\u3002<\/li>\n<li>#fff \u662f\u7eaf\u767d\u8272\u3002<\/li>\n<li>#000 \u662f\u7eaf\u9ed1\u8272\u3002<\/li>\n<\/ul>\n<p>void Widget::on_pushButton_dark_clicked()<br \/>\n{<br \/>\n     this-&gt;setStyleSheet(&#034;background-color: #333&#034;);<br \/>\n     ui-&gt;textEdit-&gt;setStyleSheet(&#034;background-color: #333; color: #fff;&#034;);<br \/>\n     ui-&gt;pushButton_light-&gt;setStyleSheet(&#034;color: #fff&#034;);<br \/>\n     ui-&gt;pushButton_dark-&gt;setStyleSheet(&#034;color: #fff&#034;);<br \/>\n}<\/p>\n<p>void Widget::on_pushButton_light_clicked()<br \/>\n{<br \/>\n     this-&gt;setStyleSheet(&#034;background-color: #f3f3f3&#034;);<br \/>\n     ui-&gt;textEdit-&gt;setStyleSheet(&#034;background-color: #fff; color: #000;&#034;);<br \/>\n     ui-&gt;pushButton_light-&gt;setStyleSheet(&#034;color: #000&#034;);<br \/>\n     ui-&gt;pushButton_dark-&gt;setStyleSheet(&#034;color: #000&#034;);<br \/>\n}<\/p>\n<p>\u5173\u4e8e\u8ba1\u7b97\u673a\u4e2d\u7684\u989c\u8272\u8868\u793a<\/p>\n<p>\u8ba1\u7b97\u673a\u4e2d\u4f7f\u7528 &#034;\u50cf\u7d20&#034; \u8868\u793a\u5c4f\u5e55\u4e0a\u7684\u4e00\u4e2a\u57fa\u672c\u5355\u4f4d(\u4e5f\u5c31\u662f\u4e00\u4e2a\u53d1\u4eae\u7684\u5149\u70b9)\u3002<\/p>\n<p>\u6bcf\u4e2a\u5149\u70b9\u90fd\u4f7f\u7528\u4e09\u4e2a\u5b57\u8282\u8868\u793a\u989c\u8272&#xff0c;\u5206\u522b\u662f R (red), G (green), B (blue) \u4e00\u4e2a\u5b57\u8282\u8868\u793a(\u53d6\u503c\u8303\u56f4\u662f 0-255&#xff0c;\u6216\u8005 0x00-0xFF)\u3002<\/p>\n<p>\u6df7\u5408\u4e09\u79cd\u4e0d\u540c\u989c\u8272\u7684\u6570\u503c\u6bd4\u4f8b&#xff0c;\u5c31\u80fd\u642d\u914d\u51fa\u5343\u5343\u4e07\u4e07\u7684\u989c\u8272\u51fa\u6765\u3002<\/p>\n<ul>\n<li>rgb(255, 0, 0) \u6216\u8005 #FF0000 \u6216\u8005 #F00 \u8868\u793a\u7eaf\u7ea2\u8272\u3002<\/li>\n<li>rgb(0, 255, 0) \u6216\u8005 #00FF00 \u6216\u8005 #0F0 \u8868\u793a\u7eaf\u7eff\u8272\u3002<\/li>\n<li>rgb(0, 0, 255) \u6216\u8005 #0000FF \u6216\u8005 #00F \u8868\u793a\u7eaf\u84dd\u8272\u3002<\/li>\n<li>rgb(255, 255, 255) \u6216\u8005 #FFFFFF \u6216\u8005 #FFF \u8868\u793a\u7eaf\u767d\u8272\u3002<\/li>\n<li>rgb(0, 0, 0) \u6216\u8005 #000000 \u6216\u8005 #000 \u8868\u793a\u7eaf\u9ed1\u8272\u3002<\/li>\n<\/ul>\n<p>\u5f53\u7136&#xff0c;\u4e0a\u8ff0\u89c4\u5219\u53ea\u662f\u9488\u5bf9\u4e00\u822c\u7684\u7a0b\u5e8f\u800c\u8a00\u662f\u8fd9\u4e48\u8bbe\u5b9a\u7684\u3002\u5b9e\u9645\u7684\u663e\u793a\u5668&#xff0c;\u53ef\u80fd\u6709 8bit \u8272\u6df1\u6216\u8005 10bit \u8272\u6df1\u7b49&#xff0c;\u5b9e\u9645\u60c5\u51b5\u4f1a\u66f4\u52a0\u590d\u6742\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"239\" src=\"2026-10-29lgmq5a2yked.png\" width=\"300\" \/><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"240\" src=\"2026-10-29l01lbaulymv.png\" width=\"300\" \/><\/p>\n<h4 id=\"%E5%8F%96%E8%89%B2%E5%99%A8\" style=\"background-color:transparent\">\u53d6\u8272\u5668<\/h4>\n<p>QQ \u548c \u5fae\u4fe1 \u7684\u622a\u56fe\u81ea\u5e26\u53d6\u8272\u5668&#xff0c;\u622a\u56fe\u7684\u65f6\u5019\u628a\u9f20\u6807\u653e\u5230\u5bf9\u5e94\u4f4d\u7f6e\u5c31\u53ef\u4ee5\u663e\u793a\u8272\u503c<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"806\" src=\"2026-10-29p44453m0qn3.png\" width=\"1079\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u5f55 1. \u63a7\u4ef6\u6982\u8ff0<br \/>\n2. QWidget \u6838\u5fc3\u5c5e\u6027<br \/>\n2.1 QWidget \u5e38\u7528\u5c5e\u6027\u4e00\u89c8<br \/>\n2.2 enabled&#xff08;\u63a7\u4ef6\u4f7f\u80fd&#xff09;<br \/>\n2.3 geometry&#xff08;\u4f4d\u7f6e\/\u5c3a\u5bf8&#xff09;<br \/>\n\u4ee3\u7801\u793a\u4f8b&#xff1a;\u63a7\u5236\u6309\u94ae\u7684\u4f4d\u7f6e<br \/>\n\u4ee3\u7801\u793a\u4f8b&#xff1a;\u4e00\u4e2a\u8868\u767d\u7a0b\u5e8f<br \/>\nwindow frame \u7684\u5f71\u54cd<br \/>\n2.4 windowTitle&#xff08;\u9876\u5c42\u7a97\u53e3\u6807\u9898&#xff09;<br \/>\n2.5 windowIcon&#xff08;\u9876\u5c42\u7a97<\/p>\n","protected":false},"author":2,"featured_media":119274,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[218,190],"topic":[],"class_list":["post-119294","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-qt","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Qt\u5e38\u7528\u63a7\u4ef6\uff1aQWidget\u5e38\u7528\u5c5e\u6027\uff0c\u63a7\u4ef6\u4f7f\u80fd\u3001\u4f4d\u7f6e\u5c3a\u5bf8\u3001\u9876\u5c42\u7a97\u53e3\u6807\u9898\/\u56fe\u6807\u3001\u900f\u660e\u5ea6\u3001\u9f20\u6807\u3001\u5b57\u4f53\u3001\u9f20\u6807\u60ac\u505c\u63d0\u793a\u3001\u7126\u70b9\u3001widget\u6837\u5f0f\uff08\u53d6\u8272\u5668\u7b49\uff09 - \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\/119294.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Qt\u5e38\u7528\u63a7\u4ef6\uff1aQWidget\u5e38\u7528\u5c5e\u6027\uff0c\u63a7\u4ef6\u4f7f\u80fd\u3001\u4f4d\u7f6e\u5c3a\u5bf8\u3001\u9876\u5c42\u7a97\u53e3\u6807\u9898\/\u56fe\u6807\u3001\u900f\u660e\u5ea6\u3001\u9f20\u6807\u3001\u5b57\u4f53\u3001\u9f20\u6807\u60ac\u505c\u63d0\u793a\u3001\u7126\u70b9\u3001widget\u6837\u5f0f\uff08\u53d6\u8272\u5668\u7b49\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u76ee\u5f55 1. \u63a7\u4ef6\u6982\u8ff0 2. QWidget \u6838\u5fc3\u5c5e\u6027 2.1 QWidget \u5e38\u7528\u5c5e\u6027\u4e00\u89c8 2.2 enabled&#xff08;\u63a7\u4ef6\u4f7f\u80fd&#xff09; 2.3 geometry&#xff08;\u4f4d\u7f6e\/\u5c3a\u5bf8&#xff09; \u4ee3\u7801\u793a\u4f8b&#xff1a;\u63a7\u5236\u6309\u94ae\u7684\u4f4d\u7f6e \u4ee3\u7801\u793a\u4f8b&#xff1a;\u4e00\u4e2a\u8868\u767d\u7a0b\u5e8f window frame \u7684\u5f71\u54cd 2.4 windowTitle&#xff08;\u9876\u5c42\u7a97\u53e3\u6807\u9898&#xff09; 2.5 windowIcon&#xff08;\u9876\u5c42\u7a97\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/119294.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-29T01:17:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011749-6ae29ebdddebb.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=\"12 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/119294.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/119294.html\",\"name\":\"Qt\u5e38\u7528\u63a7\u4ef6\uff1aQWidget\u5e38\u7528\u5c5e\u6027\uff0c\u63a7\u4ef6\u4f7f\u80fd\u3001\u4f4d\u7f6e\u5c3a\u5bf8\u3001\u9876\u5c42\u7a97\u53e3\u6807\u9898\/\u56fe\u6807\u3001\u900f\u660e\u5ea6\u3001\u9f20\u6807\u3001\u5b57\u4f53\u3001\u9f20\u6807\u60ac\u505c\u63d0\u793a\u3001\u7126\u70b9\u3001widget\u6837\u5f0f\uff08\u53d6\u8272\u5668\u7b49\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-29T01:17:55+00:00\",\"dateModified\":\"2026-10-29T01:17:55+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/119294.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/119294.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/119294.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Qt\u5e38\u7528\u63a7\u4ef6\uff1aQWidget\u5e38\u7528\u5c5e\u6027\uff0c\u63a7\u4ef6\u4f7f\u80fd\u3001\u4f4d\u7f6e\u5c3a\u5bf8\u3001\u9876\u5c42\u7a97\u53e3\u6807\u9898\/\u56fe\u6807\u3001\u900f\u660e\u5ea6\u3001\u9f20\u6807\u3001\u5b57\u4f53\u3001\u9f20\u6807\u60ac\u505c\u63d0\u793a\u3001\u7126\u70b9\u3001widget\u6837\u5f0f\uff08\u53d6\u8272\u5668\u7b49\uff09\"}]},{\"@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":"Qt\u5e38\u7528\u63a7\u4ef6\uff1aQWidget\u5e38\u7528\u5c5e\u6027\uff0c\u63a7\u4ef6\u4f7f\u80fd\u3001\u4f4d\u7f6e\u5c3a\u5bf8\u3001\u9876\u5c42\u7a97\u53e3\u6807\u9898\/\u56fe\u6807\u3001\u900f\u660e\u5ea6\u3001\u9f20\u6807\u3001\u5b57\u4f53\u3001\u9f20\u6807\u60ac\u505c\u63d0\u793a\u3001\u7126\u70b9\u3001widget\u6837\u5f0f\uff08\u53d6\u8272\u5668\u7b49\uff09 - \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\/119294.html","og_locale":"zh_CN","og_type":"article","og_title":"Qt\u5e38\u7528\u63a7\u4ef6\uff1aQWidget\u5e38\u7528\u5c5e\u6027\uff0c\u63a7\u4ef6\u4f7f\u80fd\u3001\u4f4d\u7f6e\u5c3a\u5bf8\u3001\u9876\u5c42\u7a97\u53e3\u6807\u9898\/\u56fe\u6807\u3001\u900f\u660e\u5ea6\u3001\u9f20\u6807\u3001\u5b57\u4f53\u3001\u9f20\u6807\u60ac\u505c\u63d0\u793a\u3001\u7126\u70b9\u3001widget\u6837\u5f0f\uff08\u53d6\u8272\u5668\u7b49\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u76ee\u5f55 1. \u63a7\u4ef6\u6982\u8ff0 2. QWidget \u6838\u5fc3\u5c5e\u6027 2.1 QWidget \u5e38\u7528\u5c5e\u6027\u4e00\u89c8 2.2 enabled&#xff08;\u63a7\u4ef6\u4f7f\u80fd&#xff09; 2.3 geometry&#xff08;\u4f4d\u7f6e\/\u5c3a\u5bf8&#xff09; \u4ee3\u7801\u793a\u4f8b&#xff1a;\u63a7\u5236\u6309\u94ae\u7684\u4f4d\u7f6e \u4ee3\u7801\u793a\u4f8b&#xff1a;\u4e00\u4e2a\u8868\u767d\u7a0b\u5e8f window frame \u7684\u5f71\u54cd 2.4 windowTitle&#xff08;\u9876\u5c42\u7a97\u53e3\u6807\u9898&#xff09; 2.5 windowIcon&#xff08;\u9876\u5c42\u7a97","og_url":"https:\/\/www.wsisp.com\/helps\/119294.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-29T01:17:55+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029011749-6ae29ebdddebb.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"12 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/119294.html","url":"https:\/\/www.wsisp.com\/helps\/119294.html","name":"Qt\u5e38\u7528\u63a7\u4ef6\uff1aQWidget\u5e38\u7528\u5c5e\u6027\uff0c\u63a7\u4ef6\u4f7f\u80fd\u3001\u4f4d\u7f6e\u5c3a\u5bf8\u3001\u9876\u5c42\u7a97\u53e3\u6807\u9898\/\u56fe\u6807\u3001\u900f\u660e\u5ea6\u3001\u9f20\u6807\u3001\u5b57\u4f53\u3001\u9f20\u6807\u60ac\u505c\u63d0\u793a\u3001\u7126\u70b9\u3001widget\u6837\u5f0f\uff08\u53d6\u8272\u5668\u7b49\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-29T01:17:55+00:00","dateModified":"2026-10-29T01:17:55+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/119294.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/119294.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/119294.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Qt\u5e38\u7528\u63a7\u4ef6\uff1aQWidget\u5e38\u7528\u5c5e\u6027\uff0c\u63a7\u4ef6\u4f7f\u80fd\u3001\u4f4d\u7f6e\u5c3a\u5bf8\u3001\u9876\u5c42\u7a97\u53e3\u6807\u9898\/\u56fe\u6807\u3001\u900f\u660e\u5ea6\u3001\u9f20\u6807\u3001\u5b57\u4f53\u3001\u9f20\u6807\u60ac\u505c\u63d0\u793a\u3001\u7126\u70b9\u3001widget\u6837\u5f0f\uff08\u53d6\u8272\u5668\u7b49\uff09"}]},{"@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\/119294","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=119294"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/119294\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/119274"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=119294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=119294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=119294"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=119294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}