pywebview: Error: incompatible type of argument(s) in call to call(); candidates were call(QString,QJsonValue)

Specification

  • Platform:raspberry pi arm64 ubuntu
  • Version: pywebview-2.2.1 python3

Description

first,I according to the doc, apt isntall qt5-default apt install python3-pyqt5 python3-pyqt5.qtwebkit libqt5webkit5-dev

but i cant run test,I found the pyqts version is 5.5.1, and debug found can`t import QtWebEngineWidgets,so I edit version check in qt.py of source,I try import from PyQt5 import QtWebKitWidgets and it works.

then,I try examples for https://pywebview.flowrl.com/examples/js_api.html click “Hello Python” button nothing happen,so i try catch the function pywebview.api.init().then(showResponse)

I got: Error: incompatible type of argument(s) in call to call(); candidates were call(QString,QJsonValue)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

I refactored the code, so that it determines at the import stage whether WebEngine is available and sets a flag accordingly or not and the rest of conditionals are based on that flag. Version check is completely gone. In addition to installations instructions, WebEngine Travis builds need to be figured out as well. Travis provides Ubuntu Xenial at best, which comes with QT5.5.

@r0x0r It is works on ubuntu16 used qt-5.5.1,at the same time,I did test on ubuntu18 used qt-5.10,it is not works,so I viewed the qt.py source code,I think it is not good what import QtWebkit or QtWebEngineWidgets by qt`s version, QtWebEngineWidgets and QtWebkit is Two different components,so use QtWebEngineWidgets need apt install python3-pyqt5.qtwebengine python3-pyqt5.qtwebchannel and use QtWebkit apt install python3-pyqt5.qtwebkit.They have nothing to do with versions.Just QtWebEngineWidgets provide since qt5.6

@shivaprsdv I did this test by hand,In fact,ubuntu 16(qt5.5) only provide qt5-webkit,ubuntu18(qt5.10) provide qt5-webkit and qt5-webengine,qt5-webchannel

so if you want use QtWebEngineWidgets,you need : apt install python3-pyqt5.qtwebengine apt install python3-pyqt5.qtwebchannel

if you want use QtWebKitWidgets,you need: apt install python3-pyqt5.qtwebkit

qt5 @r0x0r maybe I understand why happen this problems,I run ubuntu 16.04 on my raspberry pi arm64,then I run ubuntu 18.01 on my desktop,I found qt 5.5 on ubuntu 16.04,qt 5.10 on ubuntu 18.01,the ubuntu 16(qt5.5) provide qt5-webkit,ubuntu18(qt5.10) provide qt5-webkit and qt5-webengine,qt5-webchannel,I found removed webkit begin qt5.6 on https://wiki.qt.io/New_Features_in_Qt_5.6 (With Qt 5.6 the following modules are no longer part of the release packages, but users can still build them from source: Qt WebKit Qt Declarative (Qt Quick 1))

so, We want use WebKit: apt install python3-pyqt5.qtwebkit

We want use Webengine: apt install python3-pyqt5.qtwebengine apt install python3-pyqt5.qtwebchannel but this only provide qt >5.5 on ubuntu18,this doc maybe need fix:

20190125-102401

To be honest,I don`t have to use qt,but I don’t know how gtk run on fb device alone,but qt provide this way

And this, try: qtype = QtCore.QJsonValue # qt 5.5 this line will no error,so qtype will is QtCore.QJsonValue,but it will bring Error: incompatible type of argument(s) in call to call(); candidates were call(QString,QJsonValue) on js excute python api if qt is 5.5,so I fix qtype=str except AttributeError: qtype = str # QT4