Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/124.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何用双引号打断一条长线?_C++_Formatting - Fatal编程技术网

C++ 如何用双引号打断一条长线?

C++ 如何用双引号打断一条长线?,c++,formatting,C++,Formatting,例如,在我的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; s

例如,在我的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“
结束行以插入换行符)。

是的,你说得对,最好是缩进引号。@BrianBi我实际上只是想对你的答案发表评论,但很难在一行上写多行布局!干杯。