How to modify the comments style of Qtcreator
-
Qtcreator 4.10.1
qt 5.13.2The 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
-
Just upgrade Creator, in newer Versions it works like you want.
-
unfortunately it does not seem to be an option, because I also liked the old more :(
-
@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: 40background: 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 */ }}