应用自动布局
您可以在 Figma 中对画布或组件使用自动布局,使设计能够动态响应内容变化。画布中的元素会根据方向、间距、内边距、对齐方式及其他自动布局属性自动排列。例如,您可以创建可调整大小的屏幕、按钮和列表。
该插件将水平和垂直自动布局的画框及组件转换为 QML 实例FlexboxLayout 。
FlexboxLayout 该实例会沿其父级所有四条边进行布局,并以画面的内边距作为间距。除非您将其转换为Qt for MCUs 或关闭自动布局设置,否则画面内的图层将由布局决定位置。在Figma中设置为Ignore auto layout 的图层,在QML中仍会遵循其约束。
请注意以下限制:
- 网格自动布局框架会被转换为其他类型的 QML 组件。
- 受 Qt 框架限制,每个方向(水平或垂直)仅有一个轴能正常工作。
- 自动布局与特效、旋转、翻转以及高级自动布局属性配合使用时效果不佳。
- FlexboxLayout Qt for MCUs 不支持此功能。
要启用转换为FlexboxLayout :
- 在插件中,进入“
”(Settings )>“Code ”。
在插件的“设置”页面中,于“代码设置”部分选择“FlexboxLayout ”作为自动布局选项。
- 选择 Use FlexboxLayout for auto layout。
- 在 Figma 中,选择一个水平或垂直的自动布局框架或组件。
- 在插件中,选择“
”(Preview )以查看结果。
另请参阅 “将约束转换为锚点”、“转换设计”、“预览转换后的设计”、“下载转换后的设计”和“保存资源”。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.