例如,在我的 C++ 代码中:
setStyleSheet
(
"QPushButton{background-color:#9dce2c; border-radius:7px; border:1px solid #83c41a; color:#000000; font-size:15px; font-weight:bold; padding:4px 24px; text-decoration:none; }"
"QPushButton:pressed { border:2px; solid black; }"
"QPushButton:hover { background-color:grey; }"
"QPushButton:focus { outline: none; }"
"QGroupBox { font-size:15px; font-weight:bold; padding:6px 0px; text-decoration:underline; }"
);
有什么想法吗?
最佳答案
C 和 C++ 会自动连接相邻的字符串文字,因此您可以这样做
setStyleSheet
(
"QPushButton{background-color:#9dce2c; border-radius:7px;"
" border:1px solid #83c41a; color:#000000; font-size:15px;"
" font-weight:bold; padding:4px 24px; text-decoration:none; }"
// ...
);
它会按预期工作。 (这里不需要缩进,但我认为表明这里的第二行和第三行是第一行的延续是一种很好的风格。)
关于c++ - 如何打破双引号中的长行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22259661/