Unable to convert a C++ 'QWebEngineFindTextResult' instance to a Python object
Phil Thompson
phil at riverbankcomputing.com
Thu May 7 17:38:05 BST 2020
On 07/05/2020 15:25, Florian Bruhin wrote:
> Hey,
>
> I got a report from someone using:
>
> - Qt 5.14.1 (both QT_VERSION_STR and qVersion())
> - PyQt 5.14.1
> - sip 4.19.21
>
> - QtWebEngine 5.14.1
> - PyQtWebEngine 5.14.0 (note the .0)
>
> - Python 3.6.10
> - Gentoo Linux
>
> Where emitting the QWebEnginePage.findTextFinished signal (added in Qt
> 5.14)
> results in:
>
> TypeError: unable to convert a C++ 'QWebEngineFindTextResult'
> instance to a
> Python object
>
> In a similar vein, trying to import it via:
>
> python3 -c "from PyQt5.QtWebEngineCore import
> QWebEngineFindTextResult"
>
> results in:
>
> ImportError: cannot import name 'QWebEngineFindTextResult'
>
> Test script:
>
> --------------------------------------------------
>
> from PyQt5.QtWebEngineWidgets import QWebEngineView
> from PyQt5.QtWidgets import QApplication
> from PyQt5.QtCore import QUrl, QTimer, pyqtSlot
>
> app = QApplication([])
>
> view = QWebEngineView()
> view.load(QUrl('https://qutebrowser.org'))
> view.show()
>
> # @pyqtSlot('QWebEngineFindTextResult')
> def slot(result):
> print(result.numberOfMatches())
> app.quit()
>
> view.page().findTextFinished.connect(slot)
> QTimer.singleShot(5000, lambda: view.findText("qutebrowser"))
>
> app.exec_()
>
> --------------------------------------------------
>
> The crash happens after 5s, after findText got called. The pyqtSlot
> decorator
> doesn't change anything.
>
> I can't reproduce, and also don't know about any other people who have
> the same
> issue...
>
> Any idea what's going on there? Is their sip version too old or
> something?
> Was there a bug in QtWebEngine 5.14.0 which was fixed in .1? I don't
> understand
> what's happening, because both the findTextFinished signal and the
> QWebEngineFindTextResult class is guarded by "%If (QtWebEngine_5_14_0
> -)", so
> surely both should be available?
I can't reproduce it with current versions - sounds like their build is
screwed.
Phil
More information about the PyQt
mailing list