Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. How to modify the comments style of Qtcreator
Qt 6.11 is out! See what's new in the release blog

How to modify the comments style of Qtcreator

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
5 Posts 4 Posters 920 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.
  • B Offline
    B Offline
    BaoFanTing
    wrote on last edited by
    #1

    Qtcreator 4.10.1
    qt 5.13.2

    The comments style I want is as follows:

    TextField {
        id: textField
        width: 200
        height: 40
      
        background: Rectangle {
            color: "lightgray"
            border.color: "black"
            border.width: 1
            radius: 4
        }
        contentItem: Text {
            //anchors.fill: parent
            //text: textField.text
            //color: "black"
            //verticalAlignment: Text.AlignVCenter
            //eftPadding: 10
            //topPadding: 10 // 根据需要调整
        }
    }
    

    But when my qtcreator presses Ctrl+/, the comment code given always starts with "//" at the beginning of a line,such as:

    TextField {
        id: textField
        width: 200
        height: 40
      
        background: Rectangle {
            color: "lightgray"
            border.color: "black"
            border.width: 1
            radius: 4
        }
        contentItem: Text {
    //        anchors.fill: parent
    //        text: textField.text
    //        color: "black"
    //        verticalAlignment: Text.AlignVCenter
    //        eftPadding: 10
    //        topPadding: 10 // 根据需要调整
        }
    }
    

    How should I set it up

    1 Reply Last reply
    0
    • aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Just upgrade Creator, in newer Versions it works like you want.

      Qt has to stay free or it will die.

      J.HilkJ 1 Reply Last reply
      0
      • aha_1980A aha_1980

        Just upgrade Creator, in newer Versions it works like you want.

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @aha_1980 ! is that a setting option? I think I would prefer the old style


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        0
        • aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          unfortunately it does not seem to be an option, because I also liked the old more :(

          Qt has to stay free or it will die.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            Bon Jovi
            wrote on last edited by
            #5

            @clashdle In Qt Creator, the default Ctrl+/ behavior adds // at the beginning of each line and isn’t directly configurable for QML comments. However, you can use block comments (/* ... */) in QML to achieve a custom style. For example:
            TextField {
            id: textField
            width: 200
            height: 40

            background: Rectangle {
                color: "lightgray"
                border.color: "black"
                border.width: 1
                radius: 4
            }
            
            contentItem: Text {
                /* anchors.fill: parent
                   text: textField.text
                   color: "black"
                   verticalAlignment: Text.AlignVCenter
                   leftPadding: 10
                   topPadding: 10 // adjust as needed */
            }
            

            }

            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 Extensions
            • Unsolved