Active Topics

 


Reply
Thread Tools
xerxes2's Avatar
Posts: 513 | Thanked: 651 times | Joined on Feb 2011 @ Sweden
#1
So pyqt-5.1 was just relased and it works pretty good so far with qt-5.1.1 but I've got one problem that I can't seem to fix. The QQuickImageProvider requestPixmap method gives an error from qml:

Code:
from PyQt5 import QtCore
from PyQt5 import QtGui
from PyQt5 import QtWidgets
from PyQt5 import QtQml
from PyQt5 import QtQuick

class ImageProviderGUI(QtCore.QObject):
    def __init__(self):
        QtCore.QObject.__init__(self)
        self.app = QtWidgets.QApplication(["ImageProvider"])
        self.view = QtQuick.QQuickView()
        self.view.setResizeMode(QtQuick.QQuickView.SizeRootObjectToView)
        self.context = self.view.rootContext()
        engine = self.context.engine()
        self.image_provider = ImageProvider()
        engine.addImageProvider("cover", self.image_provider)
        self.view.setSource(QtCore.QUrl("test.qml"))
        self.view.show()
        self.app.exec_()

class ImageProvider(QtQuick.QQuickImageProvider):
    def __init__(self):
        QtQuick.QQuickImageProvider.__init__(self, QtQuick.QQuickImageProvider.Pixmap)
    
    def requestPixmap(self, id, size):
        pixmap = QtGui.QPixmap(100, 100)
        pixmap.fill(QtGui.QColor(id))
        return pixmap
    
ImageProviderGUI()
Code:
import QtQuick 2.0
//import QtQuick 1.1

Image {
        source: "image://cover/red"
}
Code:
TypeError: invalid result type from ImageProvider.requestPixmap()
file:///home/xerxes2/test.qml:5:1: QML Image: Failed to get image from provider: image://cover/red
The same thing works just fine with Pyside:
Code:
from PySide import QtCore
from PySide import QtGui
from PySide import QtDeclarative

class ImageProviderGUI(QtCore.QObject):
    def __init__(self):
        QtCore.QObject.__init__(self)
        self.app = QtGui.QApplication(["ImageProvider"])
        self.view = QtDeclarative.QDeclarativeView()
        self.view.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView)
        self.context = self.view.rootContext()
        engine = self.context.engine()
        self.image_provider = ImageProvider()
        engine.addImageProvider("cover", self.image_provider)
        self.view.setSource("test.qml")
        self.view.show()
        self.app.exec_()

class ImageProvider(QtDeclarative.QDeclarativeImageProvider):
    def __init__(self):
        QtDeclarative.QDeclarativeImageProvider.__init__(self, QtDeclarative.QDeclarativeImageProvider.Pixmap)
    
    def requestPixmap(self, id, size, requestedsize):
        pixmap = QtGui.QPixmap(100, 100)
        pixmap.fill(QtGui.QColor(id))
        return pixmap
    
ImageProviderGUI()
Any help appreciated. If it's a bug outside of my own code it would be nice to figure out if it's in qt or pyqt too.
__________________
But the WM7 "horse" has a blood lineage tracing back to donkeys such as WM6.5, 6.1, 6.0, 5.1 that was fully neglected for too many years and Microsoft did sweet F all to maintain it (still running on Pocket IE4/6!!).
 

The Following User Says Thank You to xerxes2 For This Useful Post:
xerxes2's Avatar
Posts: 513 | Thanked: 651 times | Joined on Feb 2011 @ Sweden
#2
Got a response on the pyqt mailing list:
http://www.riverbankcomputing.com/pi...er/033280.html

So now Panucci seems to be 100% working on pyqt5.
__________________
But the WM7 "horse" has a blood lineage tracing back to donkeys such as WM6.5, 6.1, 6.0, 5.1 that was fully neglected for too many years and Microsoft did sweet F all to maintain it (still running on Pocket IE4/6!!).
 

The Following 4 Users Say Thank You to xerxes2 For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 07:42.