久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  1. <tfoot id='RCxIs'></tfoot>

      <small id='RCxIs'></small><noframes id='RCxIs'>

    1. <legend id='RCxIs'><style id='RCxIs'><dir id='RCxIs'><q id='RCxIs'></q></dir></style></legend>

        <bdo id='RCxIs'></bdo><ul id='RCxIs'></ul>
    2. <i id='RCxIs'><tr id='RCxIs'><dt id='RCxIs'><q id='RCxIs'><span id='RCxIs'><b id='RCxIs'><form id='RCxIs'><ins id='RCxIs'></ins><ul id='RCxIs'></ul><sub id='RCxIs'></sub></form><legend id='RCxIs'></legend><bdo id='RCxIs'><pre id='RCxIs'><center id='RCxIs'></center></pre></bdo></b><th id='RCxIs'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='RCxIs'><tfoot id='RCxIs'></tfoot><dl id='RCxIs'><fieldset id='RCxIs'></fieldset></dl></div>

      為 QPrintWidget、QPrintPrevwiwWidget 添加頁腳

      Adding a footer to QPrintWidget, QPrintPreviwWidget(為 QPrintWidget、QPrintPrevwiwWidget 添加頁腳)
        <tfoot id='pxjNF'></tfoot><legend id='pxjNF'><style id='pxjNF'><dir id='pxjNF'><q id='pxjNF'></q></dir></style></legend>
          <bdo id='pxjNF'></bdo><ul id='pxjNF'></ul>

              <tbody id='pxjNF'></tbody>

            <small id='pxjNF'></small><noframes id='pxjNF'>

            <i id='pxjNF'><tr id='pxjNF'><dt id='pxjNF'><q id='pxjNF'><span id='pxjNF'><b id='pxjNF'><form id='pxjNF'><ins id='pxjNF'></ins><ul id='pxjNF'></ul><sub id='pxjNF'></sub></form><legend id='pxjNF'></legend><bdo id='pxjNF'><pre id='pxjNF'><center id='pxjNF'></center></pre></bdo></b><th id='pxjNF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='pxjNF'><tfoot id='pxjNF'></tfoot><dl id='pxjNF'><fieldset id='pxjNF'></fieldset></dl></div>

                本文介紹了為 QPrintWidget、QPrintPrevwiwWidget 添加頁腳的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我的發(fā)票

                我在 Python 中有一個幾乎完成的項目,它使用 QPrintPreviwDialog 根據(jù)上圖顯示和打印數(shù)據(jù).我使用 QTextDocumento 來處理 HTML.

                有沒有辦法在頁碼空間中寫一些東西.我想將黃色信息寫入頁碼空間作為頁腳.或者是否有其他解決方案來顯示頁腳而不是使用不屬于 python 的 pyjasper?

                解決方案

                My Invoice

                I have a almost finishd project in Python which uses QPrintPreviwDialog to show and print data according to the picture above. I have used QTextDocumento to handle the HTML.

                Is there a way to write something in page number space. I would like to write the info in yellow to the page number space to serve as footer. Or is there other solution to show footer instead of using pyjasper, one that are not part of python?

                解決方案

                Translating my previous answer from C++ to python and modifying the position of the text I show how to add a footer.

                from PyQt5 import QtCore, QtGui, QtWidgets, QtPrintSupport
                
                textMargins = 12
                borderMargins = 10
                
                def mmToPixels(printer, mm):
                    return mm * 0.039370147 * printer.resolution()
                
                def paintPage(pageNumber, pageCount, painter, doc, textRect, footerHeight):
                    painter.save()
                    textPageRect = QtCore.QRectF(QtCore.QPointF(0, pageNumber*doc.pageSize().height()), doc.pageSize())
                    painter.setClipRect(textRect)
                    painter.translate(0, -textPageRect.top())
                    painter.translate(textRect.left(), textRect.top())
                    doc.drawContents(painter)
                    painter.restore()
                    footerRect = QtCore.QRectF(textRect)
                    footerRect.setTop(textRect.bottom())
                    footerRect.setHeight(footerHeight)
                
                    # draw footer
                    painter.save()
                    pen = painter.pen()
                    pen.setColor(QtCore.Qt.blue)
                    painter.setPen(pen)
                    painter.drawText(footerRect, QtCore.Qt.AlignCenter, "Page {} of {}".format(pageNumber+1, pageCount))
                    painter.restore()
                
                
                def printDocument(printer, doc):
                    painter = QtGui.QPainter(printer)
                    doc.documentLayout().setPaintDevice(printer)
                    doc.setPageSize(QtCore.QSizeF(printer.pageRect().size()))
                    pageSize = printer.pageRect().size()
                    tm = mmToPixels(printer, textMargins)
                    footerHeight = painter.fontMetrics().height()
                    textRect = QtCore.QRectF(tm, tm, pageSize.width() - 2 * tm, pageSize.height() - 2 * tm - footerHeight)
                    doc.setPageSize(textRect.size())
                    pageCount = doc.pageCount()
                
                    for pageIndex in range(pageCount):
                        if pageIndex != 0:
                            printer.newPage()
                        paintPage(pageIndex, pageCount, painter, doc, textRect, footerHeight)
                
                if __name__ == '__main__':
                    import sys
                
                    app = QtWidgets.QApplication(sys.argv)
                    document = QtGui.QTextDocument()
                    cursor = QtGui.QTextCursor(document)
                    blockFormat = QtGui.QTextBlockFormat()
                
                    for i in range(10):
                        cursor.insertBlock(blockFormat)
                        cursor.insertHtml("<h1>This is the {} page</h1>".format(i+1))
                        blockFormat.setPageBreakPolicy(QtGui.QTextFormat.PageBreak_AlwaysBefore)
                
                    printer = QtPrintSupport.QPrinter(QtPrintSupport.QPrinter.HighResolution)
                    printer.setPageSize(QtPrintSupport.QPrinter.A4)
                    printer.setOutputFormat(QtPrintSupport.QPrinter.PdfFormat)
                
                    dialog = QtPrintSupport.QPrintPreviewDialog(printer)
                    dialog.paintRequested.connect(lambda print, doc=document: printDocument(printer, doc))
                
                
                    dialog.exec_()
                

                這篇關于為 QPrintWidget、QPrintPrevwiwWidget 添加頁腳的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How to bind a function to an Action from Qt menubar?(如何將函數(shù)綁定到 Qt 菜單欄中的操作?)
                PyQt progress jumps to 100% after it starts(PyQt 啟動后進度躍升至 100%)
                How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標簽設置在固定位置,以便當我向左或向右滾動時,yaxis 刻度標簽應該可見
                `QImage` constructor has unknown keyword `data`(`QImage` 構造函數(shù)有未知關鍵字 `data`)
                Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)

                  <small id='AcJCo'></small><noframes id='AcJCo'>

                      <legend id='AcJCo'><style id='AcJCo'><dir id='AcJCo'><q id='AcJCo'></q></dir></style></legend><tfoot id='AcJCo'></tfoot>
                        • <bdo id='AcJCo'></bdo><ul id='AcJCo'></ul>
                        • <i id='AcJCo'><tr id='AcJCo'><dt id='AcJCo'><q id='AcJCo'><span id='AcJCo'><b id='AcJCo'><form id='AcJCo'><ins id='AcJCo'></ins><ul id='AcJCo'></ul><sub id='AcJCo'></sub></form><legend id='AcJCo'></legend><bdo id='AcJCo'><pre id='AcJCo'><center id='AcJCo'></center></pre></bdo></b><th id='AcJCo'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='AcJCo'><tfoot id='AcJCo'></tfoot><dl id='AcJCo'><fieldset id='AcJCo'></fieldset></dl></div>

                            <tbody id='AcJCo'></tbody>
                          主站蜘蛛池模板: 日韩靠逼 | 欧美日韩手机在线观看 | 久久久精彩视频 | 国产视频久久久 | 亚洲天堂精品久久 | 在线āv视频 | 在线观看国产三级 | 一区二区视频在线 | 2019天天操| 亚洲欧美一区二区三区视频 | 国产91观看| 中文在线视频 | a在线观看 | 欧美日韩久久 | 成人性生交大片免费看r链接 | 国产精品五区 | 国产日韩欧美在线 | 日本免费在线观看视频 | 91免费小视频 | 国产美女黄色片 | 中文字幕精品一区二区三区精品 | 国产精品无码久久久久 | 午夜av在线 | 黄色小视频大全 | 国产精品久久久99 | 亚洲成人午夜电影 | 久久精品国产一区二区电影 | 涩涩操 | 欧美精品欧美精品系列 | 日韩精品一区二区三区中文在线 | 欧美成人免费在线 | 神马久久久久久久久久 | 欧美日韩在线一区二区 | 久久久精品一区 | 久久久一二三区 | 亚洲韩国精品 | 99色视频| 宅男噜噜噜66一区二区 | 成人精品一区二区 | 精品毛片在线观看 | 国产一级淫片免费视频 |