QImage.setDevicePixelRatio(2) seemed to do the trick along with a Image that is 
twice as large and manual translation of the appropriate coordinates. QPainter 
does the rest.

Good to know.

> On Mar 16, 2017, at 8:32 PM, Patrick Stinson <patrickk...@gmail.com> wrote:
> 
> That’s a good setting to know about, so thank you for pointing it out.
> 
> Unfortunately, this isn’t what I am trying to accomplish. I have a singleton 
> QGraphicsItem that acts as a canvas and is always resized to fit the view’s 
> viewport. This canvas item paints lines to a QImage buffer with each QPointF 
> that comes in from the pencil or mouse, and each call to paint() just paints 
> the QImage buffer. When the pencil or mouse is lifted, it produces a QPixmap 
> from the boundingRect of the drawn data and creates a QGraphicsPixmapItem to 
> contain it. Each pencil stroke is created in this way which works quite well 
> (undo/move/delete, etc.), except for the low-res rendering.
> 
> The canvas item uses a QImage “double-buffer” not to speed up performance but 
> to contain the pixmap data that is used to produce the pencil stroke items.
> 
> Make sense?
> 
>> On Mar 16, 2017, at 8:21 PM, Ch'Gans <chg...@gna.org> wrote:
>> 
>> On 17 March 2017 at 16:01, Patrick Stinson <patrickk...@gmail.com> wrote:
>>> Hi there!
>>> 
>>> I am implementing handwriting with the apple pencil and am double-buffering 
>>> each stroke on a QImage before passing the resulting pixmap and bounding 
>>> rect for the stroke to a QGraphicsItem. The problem is that painting to the 
>>> QImage is not at retina resolution which is what you get when you paint 
>>> directly to the scene via QGraphicsItem::paint.
>>> 
>>> Does anyone have a suggestion for how to handle this?
>>> 
>>> Should I just double the QImage size and then translate the coordinates 
>>> appropriately? Then half the target rect in QPainter::drawPixmap(const Rect 
>>> &target, const QPixmap &, const QSize &source)? Or is there a more elegant 
>>> way to do it?
>>> 
>> 
>> Have you tried QGraphicsItem::DeviceCoordinateCache ?
>> 
>> My 2 cents
>> 
>>> Thanks!
>>> -P
>>> 
>>> 
>>> _______________________________________________
>>> Interest mailing list
>>> Interest@qt-project.org
>>> http://lists.qt-project.org/mailman/listinfo/interest
> 

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to