Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1020

Pyside2-uic does not generate correct Qwebview and QQuickWidgets from UI file

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Not Evaluated
    • 5.12.5
    • 5.12.4, 5.12.1, 5.12.2, 5.12.3, 5.13.0
    • PySide
    • None
    • a2405a27e738e7a7bb379ed0ada07b317650ca09 (pyside/pyside-tools/5.12) bd27bac457943aab1082ac1c5b3f81ef9574c671 (pyside/pyside-tools/5.12)

    Description

      Hi, when using Qt Designer to create UI files and then using pyside2-uic to generate the python files, pyside2-uic does not generate the QtWebKit or QQuickWidget import statements correctly and puts them at the bottom of the file.

       

      for example, when trying to use a QWebview from qt designer, pyside2-uic generates this at the bottom:

      from PySide2 import QtWebKit

       

      this then causes issues when running as the webview that is from QtWebKit is in another place in pyside2, and i have to manually copy this in instead and remove the old module import:

      from PySide2.QtWebEngineWidgets import QWebEngineView

       

       

      here is a stack trace if that's helpful:

       

       

      Traceback (most recent call last):
       File "/home/jack/code/repos/nexus-constructor/main.py", line 11, in <module>
       from ui.addcomponent import Ui_AddComponentDialog
       File "/home/jack/code/repos/nexus-constructor/ui/addcomponent.py", line 175, in <module>
       from PySide2 import QtWebKit
       ImportError: cannot import name 'QtWebKit' from 'PySide2' (/home/jack/.local/lib/python3.7/site-packages/PySide2/_init_.py)
       Error in sys.excepthook:
       Traceback (most recent call last):
       File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
       from apport.fileutils import likely_packaged, get_recent_crashes
       File "/usr/lib/python3/dist-packages/apport/_init_.py", line 5, in <module>
       from apport.report import Report
       File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
       import apport.fileutils
       File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
       from apport.packaging_impl import impl as packaging
       File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
       import apt
       File "/usr/lib/python3/dist-packages/apt/_init_.py", line 23, in <module>
       import apt_pkg
       ModuleNotFoundError: No module named 'apt_pkg'
      Original exception was:
       Traceback (most recent call last):
       File "/home/jack/code/repos/nexus-constructor/main.py", line 11, in <module>
       from ui.addcomponent import Ui_AddComponentDialog
       File "/home/jack/code/repos/nexus-constructor/ui/addcomponent.py", line 175, in <module>
       from PySide2 import QtWebKit
       ImportError: cannot import name 'QtWebKit' from 'PySide2' (/home/jack/.local/lib/python3.7/site-packages/PySide2/_init_.py)
      

       

       

      Would be really nice to just generate the files and not have to modify them afterwards, if a UI file contains lots of web views or qquickwidgets these will have to be changed every time. 

       

      Attachments

        1. test.py
          2 kB
        2. test.ui
          1 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              ctismer Christian Tismer
              jackharper jack harper
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes