【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
相关推荐
kaixin_learn_qt_ing17 小时前
【银河麒麟下】 安装达梦数据库 + 使用Qt访问达梦数据库
qt
mengzhi啊17 小时前
缓存类CacheDataManager把临时数据存入json。做成插件·
qt·缓存·json
尘客-追梦18 小时前
Day 01:插件化之前,先看清 ABI 这堵墙
开发语言·c++·qt
Quz21 小时前
QML SwipeView:实现一个简单的图片浏览器
qt
Quz21 小时前
QML SwipeView:标签导航 与 Loader 懒加载
qt
神仙别闹1 天前
基于 QT(C++)开发的地铁换乘系统
数据库·c++·qt
进击的炸酱面1 天前
如何在服务器中使用codex?代理配置一图详解
ide·vscode·ssh
持敬chijing1 天前
VSCode 远程开发环境完整搭建指南:汉化、SSH 免密连接与版本更新锁定
ide·vscode·ssh
C++ 老炮儿的技术栈1 天前
西门子 S7 常用存储区(I/Q/M/T/C/DB/PI/PQ)
linux·开发语言·c++·windows·qt·io
j7~1 天前
【Qt】(篇二)《信号与槽:信号和槽的概述,使用、自定义信号和槽、信号与槽的连接方式、信号和槽的其他说明》---详解
qt·信号·qt5·信号与槽··qt creater