Nominate our 2022 Qt Champions!

Error paint with QDeclarativeItem on N8

  • I am doing project using QtQuick.
    I create a new type qml by QDeclarativeItem
    My class here:
    class Effect: public QDeclarativeItem {


    Effect(QDeclarativeItem* parent = 0): QDeclarativeItem(parent) {
        setFlag(QGraphicsItem::ItemHasNoContents, false);
        isBlur = false;
        isVignette = false;
    Q_PROPERTY(QString img READ myImage WRITE setMyImage NOTIFY myImageChanged)
    QString myImage();
    void setMyImage(const QString& a);
    Q_PROPERTY(int typeEffect READ type WRITE setType NOTIFY typeChanged)
    int typeEffect();
    void setType(int a);
    Q_PROPERTY(int qwidth READ qWidth WRITE setqWidth NOTIFY qWidthChanged)
    int qWidth();
    void setqWidth(int w);
    Q_PROPERTY(int qheight READ qHeight WRITE setqHeight NOTIFY qHeightChanged)
    int qHeight();
    void setqHeight(int h);
    //draw smaller-version of image for displaying
    void resizeImage();
    void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
    Q_INVOKABLE void save();
    void isBlurred(QImage& img);
    void blurSoftlight(QImage& img);
    void isVignetted(QImage& img);
    void vignetteNormal(QImage& img, const QGradient& gradient);
    void customMirror(QImage& img);
    Q_INVOKABLE void blurry() {
        isBlur = !isBlur;
            canvas = inEffect;
        } else {
            canvas = inEffect;
            inBlur = canvas;
    Q_INVOKABLE void vignette() {
        isVignette = !isVignette;
            canvas = inEffect;
        } else {
            canvas = inEffect;
            inBlur = canvas;
    //    Q_INVOKABLE void deleteTempFile() {
    //            QFile().remove(mImage);
    //    }
    //list of effects
    void forest(QImage& img);
    void sunset(QImage& img);
    void dreamy(QImage& img);
    void fall(QImage& img);
    void rainBow(QImage& img);
    void faithful(QImage& img);
    void illuminated(QImage& img);
    void breakDown(QImage& img);
    void divide(QImage& img);
    void diamond(QImage& img);
    void hdr(QImage& img);
    void vintage(QImage& img);
    void extinction(QImage& img);
    void retro(QImage& img);
    void golden(QImage& img);
    void testEffect(QImage& img);

    void myImageChanged();
    void typeChanged();
    void qWidthChanged();
    void qHeightChanged();

    int mwidth;
    int mheight;
    int radiusCircle; //radius of blurred area
    bool isBlur; //default: no blur
    bool isVignette; //default: no vignette
    QString mImage;
    int tEffect;
    QImage origin;
    QImage canvas;
    QImage preEffect;
    QImage inEffect;
    QImage inBlur;
    if choosing one of list effects, canvas will be painted by method paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
    but it does not really effective.
    Method paint:
    void Effect::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) {
    QRectF target(0, 0, mwidth, mheight);
    painter->setRenderHints(QPainter::Antialiasing, true);

    On simulator, normal
    On device N8
    Please tell me how to solve
    (My english is bad).

    [edit, picture links updated, koahnig]

  • What precisely is the problem?
    What do you expect to see?
    How is what you do see (on device) different from what you expect to see?

    Are you talking about the fact that the RHS of the item is not modified according to the effect? Or is that just an artifact of the screenshot-application? Is there something else which is incorrect?

  • On device N8, it only updates apart of image.

Log in to reply