如何以双引号打破一条线

How to break a long line in double quotes?

本文关键字:一条      更新时间:2023-10-16

例如,在我的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; }"
        // ...
    );

它将按预期工作。(这里没有必要的凹痕,但我认为表明这里的第二和第三行是第一个的连续性是很好的。)

布莱恩(Brian您需要相应地移动报价。...

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; }"
);

(如果要易于阅读的输出,则可以用n"结束行以注入新线。)