Qtcreator中的长Qstring

时间:2013-09-17 10:04:02

标签: qt ide mingw

我有很长的Qstring(html代码),当我在qtcreator中放入多行时

我收到错误,她是我收到错误的代码,所以最好的方法是

多行中的Qstring没有错误

html +=   "<!doctype html>
        <html>
            <head>
                <style type="text/css">
        html, body {
            margin: auto;
        }
        #container {
            margin-top: 41px;
            margin-left: 61px;
            margin-right: 61px;
        }
        #logo {
            text-align: center;
        }
        #client li,#entreprise li {
            text-decoration: none;
            list-style: none;
            font-size: 16px;
            margin-bottom: 6px;
        }
        #facture_num {
            text-align: center;
            font-weight: bold;
            font-family: arial;
            font-size: 21px;
            margin-top: 30px;
            margin-bottom: 30px;
        }
        #client {
            float: right;
            width: 500px;
            margin-right: 260px;
            margin-bottom: 30px;
            margin-top: -12px;
        }
        table {
            width: 1000px;
        }
        table td {
            text-align: center;
        }
        table th {
            background: #ccc;
        }

                </style>
            </head>
            <body>
        <div id="container">
                    <!-- Header of facture -->
                <div id="logo">
                    <h1>Logo d'entreprise</h1>
                </div>

                <ul id="entreprise">
                    <li>N° RC: 23131313213213132</li>
                <li>N° CF : 556465465456456456</li>

                <li></li></ul>
                <div id="facture_num">Factrue N°:...........</div>
                <ul id="client">
                    <li>Client:</li>
                        <li>N° rc: 23131313213213132</li>
                <li>N° cf : 556465465456456456</li>
                <li></li>
                </ul>
                <br>
                <br>
                <!-- body of facture -->
                <table>
                    <thead>
                        <tr>
                            <th>N°</th>
                            <th>Désignation</th>
                            <th>Qte</th>
                            <th>Prix Unitaire</th>
                            <th>Montant</th>
                        </tr>
                    </thead>

                    <tr>
                        <td>1</td>
                        <td>2</td>
                        <td>3</td>
                        <td>4</td>
                    </tr>
                    <tr>
                        <td>1</td>
                        <td>2</td>
                        <td>3</td>
                        <td>4</td>
                    </tr>
                    <tr>
                        <td>1</td>
                        <td>2</td>
                        <td>3</td>
                        <td>4</td>
                    </tr>
                    <tr>
                        <td>1</td>
                        <td>2</td>
                        <td>3</td>
                        <td>4</td>
                    </tr>
                    <tr>
                        <td>1</td>
                        <td>2</td>
                        <td>3</td>
                        <td>4</td>
                    </tr>
                    <tr>
                        <td>1</td>
                        <td>2</td>
                        <td>3</td>
                        <td>4</td>
                    </tr>
                    <tr>
                        <td>1</td>
                        <td>2</td>
                        <td>3</td>
                        <td>4</td>
                    </tr>
                    <tr>
                        <td>1</td>
                        <td>2</td>
                        <td>3</td>
                        <td>4</td>
                    </tr>
                    <tr>
                        <td>1</td>
                        <td>2</td>
                        <td>3</td>
                        <td>4</td>
                    </tr>
                    <tr>
                        <td>1</td>
                        <td>2</td>
                        <td>3</td>
                        <td>4</td>
                    </tr>
                    <tr>
                        <td>1</td>
                        <td>2</td>
                        <td>3</td>
                        <td>4</td>
                    </tr>

                    <tfoot>
                        <tr>
                            <td></td>
                        </tr>
                    </tfoot>
                </table>
                <!-- footer of facture -->
        </div>
            </body>
        </html>";

1 个答案:

答案 0 :(得分:1)

字符串在第一个引号处断开:<style type="text/css">

逃脱它:

 <style type=\"text/css\">

这是一种方法..

你需要为字符串中的每个引号执行此操作。

你还需要逃离行车

在每行的末尾添加\。

或者你可以用“<并以”

开始下一行来结束每一行