久久久久久久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>
                          主站蜘蛛池模板: 欧美xxxx在线 | 懂色一区二区三区免费观看 | 老司机67194精品线观看 | 国产一区二区视频免费在线观看 | 精品亚洲国产成av人片传媒 | www.五月天婷婷 | 日韩成人在线观看 | www.黄色片视频 | 日韩成人 | 人人干人人干人人干 | 中文字幕在线国产 | 日本成人二区 | 人人插人人 | 性做久久久久久免费观看欧美 | 91久久国产综合久久 | 自拍视频精品 | 亚洲免费在线 | 久久久久久国产精品久久 | 妹子干综合 | 亚洲一二三区免费 | 亚洲精品久久久 | 欧美a免费| 香蕉久久a毛片 | 日本一区二区视频 | 日韩精品一区二区三区在线观看 | 一区二区三区四区不卡 | 老司机免费视频 | 黄免费观看视频 | 精品在线视频播放 | 97人澡人人添人人爽欧美 | av资源网站 | 日韩精品在线网站 | 视频一区二区三区中文字幕 | av av在线| 黄色网址在线免费播放 | 成人在线免费 | 国产欧美精品一区二区 | 羞羞视频在线网站观看 | 国产一区二区精华 | 亚洲综合色自拍一区 | 日本三级在线视频 |