QQuickImageProvider error
-
Hi,
I am trying to implement a QQuickImageProvider class. My imageprovider.h:#ifndef IMAGEPROVIDER_H #define IMAGEPROVIDER_H #include <QQuickImageProvider> #include <QPixmap> #include <QObject> #include <QPainter> class ImageProvider : public QObject, public QQuickImageProvider { Q_OBJECT public: explicit ImageProvider(ImageType type, Flags flags = 0); QPixmap reqestPixmap(const QString &id, QSize *size, const QSize &requestedSize); }; #endif // IMAGEPROVIDER_H
My imageprovider.cpp so far:
#include "imageprovider.h" ImageProvider::ImageProvider(ImageType type, Flags flags) : QQuickImageProvider (type, flags) { }
When I build it I get the following error message:
C:\Programming\Android\Samples\ClassTest\imageprovider.cpp:3: error: prototype for 'ImageProvider::ImageProvider()' does not match any in class 'ImageProvider'
ImageProvider::ImageProvider()
^C:\Programming\Android\Samples\ClassTest\imageprovider.cpp:1: In file included from ..\ClassTest\imageprovider.cpp:1:0:
C:\Programming\Android\Samples\ClassTest\imageprovider.h:11: error: candidates are: ImageProvider::ImageProvider(ImageProvider&&)
class ImageProvider : public QObject, public QQuickImageProvider
^
C:\Programming\Android\Samples\ClassTest\imageprovider.h:11: error: ImageProvider::ImageProvider(const ImageProvider&)
C:\Programming\Android\Samples\ClassTest\imageprovider.h:16: error: ImageProvider::ImageProvider(QQmlImageProviderBase::ImageType, QQmlImageProviderBase::Flags)
explicit ImageProvider(ImageType type, Flags flags = 0);
^
How can I fix this error?
Thank you for your help. -
Looks like code is you pasted is not in sync with code you have ? I see 3 constructors errors in header files. You pasted only one. Please give us the complete code. It will help.
Have you tried with code example given in the assistant. It is easy and work perfectly.
class ColorImageProvider : public QQuickImageProvider
-
Hi @dheerendra ,
This is the entire code I have. It was originally 1 error message just got broken up when I copied.
When I tried originally I usedclass ImageProvider : public QQuickImageProvider { public: ImageProvider (); }
I got a message in the cpp file saying explicit definition is required.
Thank you for your help. -
Is this working now ? or still do you have problem ?
-
@dheerendra
It is still not working. -
Hi,
You likely didn't implement the ImageProvider constructor, did you ?
-
There are two options for you to check
- Under Qt Installation there is one example called Examples/Qt-5.11.0/quick/textureprovider
Please check this works or not. - Go to Qt Assistant. There is one example in the QQuickImageProvider documentation. Copy-Paste the example. Just if this works.
Both should work. If does not work, then we have different issue to solve than QQuickImageProvider issue.
- Under Qt Installation there is one example called Examples/Qt-5.11.0/quick/textureprovider