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. QQuickPaintedItem not update whole area.
Forum Updated to NodeBB v4.3 + New Features

QQuickPaintedItem not update whole area.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qquickpainteditqmlqquickitemupdate
2 Posts 1 Posters 544 Views
  • 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.
  • M Offline
    M Offline
    Mintogo
    wrote on last edited by Mintogo
    #1

    Hi

    I create class inherit form QQuickPaintedItem class.

    and write void paint(QPainter painter);*

    like below...

    // set image data to display on QQuickItem
    void QuickImageItem::setImage(const QImage &image)
    {
        this->current_image = image.mirrored(this->_flipHorizontally, !this->_flipVertically);
    
        update();
    }
    ...
    // here is paint funciton
    void QuickImageItem::paint(QPainter *painter)
    {
        if (this->image().isNull() != true)
        {
            QRectF bounding_rect = boundingRect();
    
            // do something...
    
            if (this->_cropWidth != -1 && this->_cropHeight != -1)
            {
                int imageWidth = this->image().width();
                int imageHeight = this->image().height();
    
                pixmap = pixmap.copy((imageHeight - this->_cropHeight) / 2, (imageWidth - this->_cropWidth) / 2, this->_cropHeight, this->_cropWidth);
            }
    
            painter->setRenderHints(QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform, true);
    
           // draw image
            painter->drawPixmap(0, 0, drawWidth, drawHeight, pixmap);
        }
    }
    

    first set image was darwed very well.

    but after change this->current_image it update partially.

    alt text

    Like above image.

    The black area in red rectangle is I changed image and this size is same with person image.

    I chnaged current_image variable and call update(). but not update whole image area.

    Is there something I missing?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mintogo
      wrote on last edited by
      #2

      I resolved it.

      It because of RenderTarget.

      I rollback it to default value.

      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