Solved requestPixmap causes moc errors
-
Hi @SGaist,
I implemented requestPixmap and it is working now.Would you please explain what you meant by "it's not a slot in the base case, there's not reason to change that in a subclass."
Thank you for your help.
-
@gabor53
Hi
You put requestPixmap function under slots:
public slots:
QPixmap requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) override;but its not a slot in the base class ( base class is QQuickImageProvider in your case )
its a virtual function one can override. ( as you did)
and i assume its public.
https://doc.qt.io/qt-5/qquickimageprovider.html#requestPixmap
so its not a slot, so no reason to make it a slot in your class. -
Hi ,
I removed requestPixmap from public slots. Thank you.
How can I callQPixmap requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) override;
Thank you.
-
@gabor53 said in requestPixmap causes moc errors:
QQuickImageProvider
Its explained the docs for the class
https://doc.qt.io/qt-5/qquickimageprovider.html#detailsYou will use the name in the source statement
Image { source: "image://MyImageProvider/Image.png" }note:
- I removed requestPixmap from public slots
Meaning you have moved it to public (non slot) section, i assume.
- I removed requestPixmap from public slots
-
@mrjj ,
I understand now how QML will call QQuickimageProvider. But, how can I pass the image id(path) from QML?
Thank you for your help. -
@gabor53
Hi
in what way pass ?- But, how can I pass the image id(path) from QML?
When you do
Image { source: "image://MyImageProvider/Image.png" }
i assume you will see Image.png as id. -
@mrjj,
Yes, but should I use a signal/slot to send the path from QML to C++ and call QQuickImageProvider from that slot?
Thank you. -
Hi
Nope. you register it.
"The QML engine invokes the appropriate image provider according to the providers that have been registered through QQmlEngine::addImageProvider()."
https://doc.qt.io/qt-5/qqmlengine.html#addImageProviderThen when you do
Image { source: "image://MyImageProvider/Image.png" }
if you have registered as MyImageProvider , it will automatically be called. -
Hi,
No, take a look again at the QQuickimageProvider documentation.
It shows how to use it from QML:
Image { source: "image://myimageprovider/image.png" }
-
@SGaist
Thank you. It works now.