• <tfoot id='8H5ku'></tfoot>

    <small id='8H5ku'></small><noframes id='8H5ku'>

      <bdo id='8H5ku'></bdo><ul id='8H5ku'></ul>

      <legend id='8H5ku'><style id='8H5ku'><dir id='8H5ku'><q id='8H5ku'></q></dir></style></legend>
    1. <i id='8H5ku'><tr id='8H5ku'><dt id='8H5ku'><q id='8H5ku'><span id='8H5ku'><b id='8H5ku'><form id='8H5ku'><ins id='8H5ku'></ins><ul id='8H5ku'></ul><sub id='8H5ku'></sub></form><legend id='8H5ku'></legend><bdo id='8H5ku'><pre id='8H5ku'><center id='8H5ku'></center></pre></bdo></b><th id='8H5ku'></th></span></q></dt></tr></i><div id='8H5ku'><tfoot id='8H5ku'></tfoot><dl id='8H5ku'><fieldset id='8H5ku'></fieldset></dl></div>

      1. QGraphicsSVGItem 忽略(一些)剪切路径.为什么?

        时间:2023-08-04
              <bdo id='Hgr4X'></bdo><ul id='Hgr4X'></ul>
            • <tfoot id='Hgr4X'></tfoot>
                <tbody id='Hgr4X'></tbody>
              <i id='Hgr4X'><tr id='Hgr4X'><dt id='Hgr4X'><q id='Hgr4X'><span id='Hgr4X'><b id='Hgr4X'><form id='Hgr4X'><ins id='Hgr4X'></ins><ul id='Hgr4X'></ul><sub id='Hgr4X'></sub></form><legend id='Hgr4X'></legend><bdo id='Hgr4X'><pre id='Hgr4X'><center id='Hgr4X'></center></pre></bdo></b><th id='Hgr4X'></th></span></q></dt></tr></i><div id='Hgr4X'><tfoot id='Hgr4X'></tfoot><dl id='Hgr4X'><fieldset id='Hgr4X'></fieldset></dl></div>

              <legend id='Hgr4X'><style id='Hgr4X'><dir id='Hgr4X'><q id='Hgr4X'></q></dir></style></legend>

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

                • 本文介绍了QGraphicsSVGItem 忽略(一些)剪切路径.为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  ).一种可能的解决方案是使用 QWebEngineView(python -m pip install pyqtwebengine):

                  导入操作系统导入系统从 PyQt5 导入 QtCore、QtGui、QtWidgets、QtSvg、QtWebEngineWidgetsCURRENT_DIR = os.path.dirname(os.path.realpath(__file__))如果 __name__ == '__main__':应用程序 = QtWidgets.QApplication(sys.argv)文件名 = os.path.join(CURRENT_DIR, "back-red.svg")场景 = QtWidgets.QGraphicsScene()渲染器 = QtSvg.QSvgRenderer(文件名)graphics_view = QtWidgets.QGraphicsView()graphics_view.setScene(场景)graphics_view.show()视图 = QtWebEngineWidgets.QWebEngineView()view.setContextMenuPolicy(QtCore.Qt.NoContextMenu)# view.page().setBackgroundColor(QtGui.QColor("透明"))view.resize(renderer.viewBox().size())view.load(QtCore.QUrl.fromLocalFile(文件名))item = scene.addWidget(view)graphics_view.resize(640, 480)sys.exit(app.exec())

                  This SVG image is correctly rendered in Firefox and Inkscape, but for some reason, when using QGraphicsSVGItem without anything fancy, it renders this way:

                  For reference, this is what it looks like on firefox:

                  As you can see, the back of the card is not supposed to go beyond the white border.

                  Am I doing something wrong? Is there a (preferably easy) fix?

                  MWE:

                  import sys
                  from PyQt5 import QtWidgets, QtCore, Qt, QtGui
                  
                  app = QtWidgets.QApplication(sys.argv)
                  
                  scene = QtWidgets.QGraphicsScene()
                  scene.addItem(Qt.QGraphicsSvgItem("back-red.svg"))
                  
                  graphics_view = QtWidgets.QGraphicsView()
                  graphics_view.setScene(scene)
                  graphics_view.show()
                  
                  sys.exit(app.exec())
                  

                  解决方案

                  Probably your svg does not meet the characteristics that Qt uses (for more information read here). One possible solution is to use QWebEngineView(python -m pip install pyqtwebengine):

                  import os
                  import sys
                  
                  from PyQt5 import QtCore, QtGui, QtWidgets, QtSvg, QtWebEngineWidgets
                  
                  CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))
                  
                  if __name__ == '__main__':
                  
                      app = QtWidgets.QApplication(sys.argv)
                  
                      filename = os.path.join(CURRENT_DIR, "back-red.svg")
                  
                      scene = QtWidgets.QGraphicsScene()
                  
                      renderer = QtSvg.QSvgRenderer(filename)
                  
                      graphics_view = QtWidgets.QGraphicsView()
                      graphics_view.setScene(scene)
                      graphics_view.show()
                  
                      view = QtWebEngineWidgets.QWebEngineView()
                      view.setContextMenuPolicy(QtCore.Qt.NoContextMenu)
                      # view.page().setBackgroundColor(QtGui.QColor("transparent"))
                      view.resize(renderer.viewBox().size())
                      view.load(QtCore.QUrl.fromLocalFile(filename))
                  
                      item = scene.addWidget(view)
                  
                      graphics_view.resize(640, 480)
                  
                      sys.exit(app.exec())
                  

                  这篇关于QGraphicsSVGItem 忽略(一些)剪切路径.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Python FileDialog获取文件夹路径不是文件 下一篇:我怎么能等待而不冻结主线程

                  相关文章

                  最新文章

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

                    1. <small id='5FimC'></small><noframes id='5FimC'>