Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

it can't run under pyqt5? #1

Open
dragondjf opened this issue Feb 2, 2015 · 8 comments
Open

it can't run under pyqt5? #1

dragondjf opened this issue Feb 2, 2015 · 8 comments

Comments

@dragondjf
Copy link

this wrapper work under Qt not for PyQt5, because PyQt5 don't support QtWebEngine , PyQt only support QtWebEngineWidgets. How to fix this?

@mdkcore0
Copy link
Owner

mdkcore0 commented Feb 2, 2015

Hi @dragondjf. I wrote this wrapper to allow the use of WebEngineView inside QML at a time where pyqt5 just didn't support it. I saw something related to it recently on their changelog, but had no time to check. Will try to check it later, probably they are supporting it right now.

When I wrote this, I was using PyQt 5.4-snapshot-837edec02d98 and Qt 5.4 beta, it worked at the time (I was doing some tests with maps on QML). You can take a look on the example on this repository too.

What is your specific problem? It just doesn't work? Do you have any error message? Can you provide a small piece of code with the problem, and describe what you've done to build it?

Hope to get it solved for you, see ya ;)

@dragondjf
Copy link
Author

it work well, we must run initialize() before we can use WebEngineView, to fix this, I wrote DQuickView like this, so it work nice. or you can use Loader to cotroll WebEngineWrapper initialize fininshed before use WebEngineView.

#!/usr/bin/python

import sys
import os
from PyQt5 import QtCore
from PyQt5 import QtGui
from PyQt5 import QtQuick
from PyQt5 import QtQml

class DQuickView(QtQuick.QQuickView):

"""The DQuickView init webengine in PyQt5"""

def __init__(self):
    super(DQuickView, self).__init__()
    self.initWebengine()

def initWebengine(self):
    component = QtQml.QQmlComponent(self.engine())
    component.setData('''
        import QtQuick 2.4
        import WebEngineWrapper 1.0
        WebEngineWrapper {
            Component.onCompleted: {
                initialize()
            }
        }
    ''', QtCore.QUrl(''));
    item = component.create()
    item.setParentItem(self.rootObject())

@mdkcore0
Copy link
Owner

Oh, I see. Pretty cool man!

As I just needed WebEngineView on the QML side, I had no worries on trying to initialize it direct on python. But your way works, nice!

@chirstius
Copy link

I need to use WebEngine rendering to an OpenGL surface, tried compiling this, and it doesn't seem to work (Pyhton 3.x Qt 5.7) @dragondjf - can you provide a more complete example of how you get WebEngineView to work under pyqt5 with qml/QuickView? I can't seem to suss out how to do it from your sample - apologies, I am very new to python!

@chirstius
Copy link

Actually, I think I have everything sorted, but any time I try to run the example, I get:
file:///D:/WebEngineWrapper-master/example/main.qml:4:1: plugin cannot be loaded for module "WebEngineWrapper": Cannot load library D:\WebEngineWrapper-master\build\WebEngineWrapper\webenginewrapper.dll: The specified module could not be found.
import WebEngineWrapper 1.0
^

Though, 100% the file IS there. QML2_IMPORT_PATH is set properly (changing it causes other issues so I know its being read) any ideas on why it might not be able to see the wrapper code? This is, obviously, on Windows

@mdkcore0
Copy link
Owner

Hi, I can't test it with Qt 5.7 right now, but it's working on 5.6.2 (python 2.7 and 3.5, on OSX), and PyQt5.6.

Seems there is some problem with PyQt 5.7: https://www.riverbankcomputing.com/pipermail/pyqt/2016-October/038231.html
https://www.riverbankcomputing.com/pipermail/pyqt/2016-September/038092.html

@chirstius
Copy link

Got some info from the PyQt guys that say WebEngine should be sorted out in the next release of PyQt that's due in a few weeks. I suppose I'll just wait it out and see if that really does correct things. Thanks for the response!

@IlyaBizyaev
Copy link

Hello!
Loading WebEngine from QML produces segfault. I am using Qt 5.8.
In C++ code, everything works fine; I think the reason is that in C++ there is "QtWebEngine::initialize()".
Is there still no way to use WebEngine with PyQt without wrappers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants