【QML】vscode安装QML格式化插件方法

1. 安装插件

拓展 => 搜索qml => 找到QML Format =>点击安装

2. 配置

  • 打开settings.json文件
    • ctl + shift + p,然后搜索settings
  • 修改settings.js内容
c 复制代码
{
    ...
    //添加以下内容

    // 根据自己电脑安装路径来填写qmlformat.exe的路径,注意转义符"\" => "\\"
    "qmlFormat.command": "D:\\Soft\\Qt6\\5.15.2\\mingw81_64\\bin\\qmlformat.exe",

    // 命令选项,这里官方写的是--normal,但是报错,改成-n就好了
    // qmlFormat的命令选项见附录
    "qmlFormat.extraArguments": ["-n"]
}

3. 使用

  • 鼠标右键选择格式化文档
  • 快捷键 shift + alt + F

附录

  • qmlFormat.exe 命令选项
c 复制代码
./qmlformat -h                                       
Usage: ./qmlformat [options] filenames
Formats QML files according to the QML Coding Conventions.

Options:
  -h, --help                  Displays help on commandline options.
  --help-all                  Displays help including Qt specific options.
  -v, --version               Displays version information.
  -V, --verbose               Verbose mode. Outputs more detailed information.
  -i, --inplace               Edit file in-place instead of outputting to
                              stdout.
  -f, --force                 Continue even if an error has occurred.
  -t, --tabs                  Use tabs instead of spaces.
  -w, --indent-width <width>  How many spaces are used when indenting.
  -n, --normalize             Reorders the attributes of the objects according
                              to the QML Coding Guidelines.
  -F, --files <file>          Format all files listed in file, in-place
  -l, --newline <newline>     Override the new line format to use (native macos
                              unix windows).

Arguments:
  filenames                   files to be processed by qmlformat
相关推荐
Zeluar2 小时前
关闭VSCode Markdown插件在Jupyter Notebook中的自动预览
ide·vscode·jupyter
lxmyzzs10 小时前
pyqt5无法显示opencv绘制文本和掩码信息
python·qt·opencv
大橘10 小时前
【qml-4】qml与c++交互(类型多例)
qt·qml
雷工笔记14 小时前
【软件安装】VScode介绍安装步骤及中文界面设置方法
ide·vscode·编辑器
Forward♞18 小时前
Qt——文件操作
开发语言·c++·qt
王廷胡_白嫖帝20 小时前
Qt猜数字游戏项目开发教程 - 从零开始构建趣味小游戏
开发语言·qt·游戏
王廷胡_白嫖帝1 天前
Qt密码生成器项目开发教程 - 安全可靠的随机密码生成工具
开发语言·qt
莫听穿林打叶声儿1 天前
Qt中使用QString显示平方符号(如²)
c++·qt
枫叶丹41 天前
【Qt开发】常用控件(五)
服务器·前端·qt
gaog2zh1 天前
100202Title和Input组件_编辑器-react-仿低代码平台项目
react.js·低代码·编辑器