Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Error paint with QDeclarativeItem on N8
Forum Updated to NodeBB v4.3 + New Features

Error paint with QDeclarativeItem on N8

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    withlovei
    wrote on last edited by
    #1

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

    public:

    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();
    
    //overwrite
    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;
        if(!isBlur){
            canvas = inEffect;
            isVignetted(canvas);
        } else {
            canvas = inEffect;
            isBlurred(canvas);
            inBlur = canvas;
            isVignetted(canvas);
        }
    }
    
    Q_INVOKABLE void vignette() {
        isVignette = !isVignette;
        if(!isBlur){
            canvas = inEffect;
            isVignetted(canvas);
        } else {
            canvas = inEffect;
            isBlurred(canvas);
            inBlur = canvas;
            isVignetted(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);
    

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

    private:
    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);
    painter->drawImage(target,canvas);
    update();
    }
    @

    Result.
    On simulator, normal
    !http://np8.upanh.com/b2.s28.d3/fe2fe75988319f3925e29378c2c73b4c_47659948.simulator.png!
    On device N8
    !http://np3.upanh.com/b1.s27.d1/1a57ef39e19a0955b2025a58a97981c6_47659993.nokian800.png!
    Please tell me how to solve
    (My english is bad).

    [edit, picture links updated, koahnig]

    1 Reply Last reply
    0
    • C Offline
      C Offline
      chriadam
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0
      • W Offline
        W Offline
        withlovei
        wrote on last edited by
        #3

        On device N8, it only updates apart of image.
        !http://i.imgur.com/O9mEk.png()!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved