QML and cpp:QQuickPaintedItem paint pincharea on android
-
I want to use the most simple code to implement multi-touch for resizing and moving my object.
QQ.qmlQuickPaintedStitch{//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 andthe 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); } }
-
I want to use the most simple code to implement multi-touch for resizing and moving my object.
QQ.qmlQuickPaintedStitch{//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 andthe 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); } }
@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 ?