Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QML and cpp:QQuickPaintedItem paint pincharea on android

QML and cpp:QQuickPaintedItem paint pincharea on android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 1 Posters 747 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.
  • zenghsingZ Offline
    zenghsingZ Offline
    zenghsing
    wrote on last edited by zenghsing
    #1

    I want to use the most simple code to implement multi-touch for resizing and moving my object.
    QQ.qml

    QuickPaintedStitch{//here and
            id:widgetStitch
            //anchors.fill:parent
            x:0
            z:-1
            y:imgTop.height
            width: parent.width
            height: parent.height-y-imgThreadBackground.height
            //objectName:"mPreviewStitch"
            PinchArea{
                anchors.fill: parent
                pinch.target:widgetStitch
                pinch.minimumScale: 1
                pinch.maximumScale: 3
                pinch.dragAxis: Pinch.XAndYAxis
                onPinchUpdated:
                {
                    widgetStitch.setCanRePaint(false);
                }
            }
        }
    

    quickpaintedstitch.cpp for widgetStitch
    /*
    I find the strange thing will occur when I only use the code of "bCanRePaint=true" after using pincharea.

    Hence, I add the code of "bCanRePaint=false " for pincharea.

    But there are another strange thing will occur when I only use the code after using pincharea.

    The image will be trimed for the top part when I move the image up to down by using two finger.

    (
    I capture a screenshot in below link.

    In my screenshot ,
    the top row is move my image from top to down by using two fingers and

    the bottom row is move my image from down to top by using two fingers.
    )
    https://drive.google.com/file/d/0ByVRIO9rYFrJQU91ZVZnSDZTa0U/view?usp=sharing
    Why?

    */

    
    void QuickPaintedStitch::paint(QPainter *painter)
    {
        if(bCanRePaint){
            QPainterPath BodyPath;
            BodyPath.addRect(0, 0, this->width(), this->height());
            if(gClass.getBShowMessage()){
                painter->fillPath(BodyPath, QBrush(Qt::yellow));
                painter->fillRect(this->x(),this->y(),this->width(),this->height(),Qt::yellow);
            }
            this->DrawHoop(painter);
            this->GraphicsData_Draw(painter);
            if(connectData.stitchFile!=0 && bPreviouStitchIconFinised==false){
                bPreviouStitchIconFinised=true;
                emit sendStitchIconFinished();
            }
            painter->end();
        }else{
          QRect imgRect=  QRect((this->width() - this->connectData.EmbImage->width()) / 2, (this->height() - this->connectData.EmbImage->height()) / 2,
                           this->connectData.EmbImage->width(), this->connectData.EmbImage->height());
            painter->drawImage(imgRect, *this->connectData.EmbImage);
    
        }
    
    }
    
    zenghsingZ 1 Reply Last reply
    0
    • zenghsingZ zenghsing

      I want to use the most simple code to implement multi-touch for resizing and moving my object.
      QQ.qml

      QuickPaintedStitch{//here and
              id:widgetStitch
              //anchors.fill:parent
              x:0
              z:-1
              y:imgTop.height
              width: parent.width
              height: parent.height-y-imgThreadBackground.height
              //objectName:"mPreviewStitch"
              PinchArea{
                  anchors.fill: parent
                  pinch.target:widgetStitch
                  pinch.minimumScale: 1
                  pinch.maximumScale: 3
                  pinch.dragAxis: Pinch.XAndYAxis
                  onPinchUpdated:
                  {
                      widgetStitch.setCanRePaint(false);
                  }
              }
          }
      

      quickpaintedstitch.cpp for widgetStitch
      /*
      I find the strange thing will occur when I only use the code of "bCanRePaint=true" after using pincharea.

      Hence, I add the code of "bCanRePaint=false " for pincharea.

      But there are another strange thing will occur when I only use the code after using pincharea.

      The image will be trimed for the top part when I move the image up to down by using two finger.

      (
      I capture a screenshot in below link.

      In my screenshot ,
      the top row is move my image from top to down by using two fingers and

      the bottom row is move my image from down to top by using two fingers.
      )
      https://drive.google.com/file/d/0ByVRIO9rYFrJQU91ZVZnSDZTa0U/view?usp=sharing
      Why?

      */

      
      void QuickPaintedStitch::paint(QPainter *painter)
      {
          if(bCanRePaint){
              QPainterPath BodyPath;
              BodyPath.addRect(0, 0, this->width(), this->height());
              if(gClass.getBShowMessage()){
                  painter->fillPath(BodyPath, QBrush(Qt::yellow));
                  painter->fillRect(this->x(),this->y(),this->width(),this->height(),Qt::yellow);
              }
              this->DrawHoop(painter);
              this->GraphicsData_Draw(painter);
              if(connectData.stitchFile!=0 && bPreviouStitchIconFinised==false){
                  bPreviouStitchIconFinised=true;
                  emit sendStitchIconFinished();
              }
              painter->end();
          }else{
            QRect imgRect=  QRect((this->width() - this->connectData.EmbImage->width()) / 2, (this->height() - this->connectData.EmbImage->height()) / 2,
                             this->connectData.EmbImage->width(), this->connectData.EmbImage->height());
              painter->drawImage(imgRect, *this->connectData.EmbImage);
      
          }
      
      }
      
      zenghsingZ Offline
      zenghsingZ Offline
      zenghsing
      wrote on last edited by zenghsing
      #2

      @zenghsing
      There are something I found.

      1.I find the trimmed area is
      because of "this->height() < this->connectData.EmbImage->height()".
      EX:
      this->height()=400
      this->connectData.EmbImage->height()=410
      Then the top pixels will being delete...

      2.The resize center always being in the center of object.
      How to set resized center to the center OF MY TWO FINGERS ?

      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