Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. qml代码缩进问题
Qt 6.12 LTS is out! See what's new in the release blog

qml代码缩进问题

Scheduled Pinned Locked Moved Unsolved Chinese
3 Posts 3 Posters 3.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    deslan
    wrote on last edited by deslan
    #1

    没有参数传递时缩进是这样的:

            onAddLocalClient: {
                console.log("log")
            }
    

    有参数传递时缩进时:

            onAddLocalClient:(group_name)=> {
                                 console.log("log")
                             }
    

    我想要的效果是:

            onAddLocalClient:(group_name)=> {
                console.log("log")
            }
    

    这看起来就像bug,为什么多了=>后自动对齐规则就不一样了。需要怎么设置,格式才会和没有=>时一样?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      Liang Qi
      wrote on last edited by
      #2

      什么文本编辑器下?谢谢

      1 Reply Last reply
      0
      • C Offline
        C Offline
        C_H_E_N
        wrote on last edited by C_H_E_N
        #3

        貌似是老毛病 :
        https://qt-project.atlassian.net/browse/QTCREATORBUG-30463

        可以被最新的Qt Creator 19确认,比如:

            Item {
                onXChanged: function() {
                    console.log("Hello")
                }
                onXChanged: ()=> {
                                console.log("Hello")
                            }
            }
        

        两种函数定义方法,使用builtin的code style(Preferences->Qt Quick->Code Style),写完之后Ctrl + I,结果就是这样。问题可能不是参数而是箭头函数本身。

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt
        • Unsolved