PDA

View Full Version : QBrush pixmap tiling



rbp
8th June 2008, 10:35
hello,

I have a brush constructed from a pixmap. When I set this brush to a widget the pixmap is tiled.
Is there a way to prevent this tiling?

Richard

rbp
15th June 2008, 09:42
Perhaps it will help if I tell you what I'm trying to do.

I made an image editor program but it is slow because I redraw the image after every edit. The base image does not change so I'm trying to set it as a background.

I tried using a brush, which made the program much more responsive, but it tiled the image to fit its container instead of resizing it.

Do you another approach to achieve this?

aamer4yu
17th June 2008, 07:37
what are you using the brush on ?? QWidget ?
You can simple use QPainter::drawPixmap to draw the Pixmap.

rbp
17th June 2008, 11:08
I'm using a graphicscene within a graphicview to display the image so I can zoom.
I tried puting the drawPixmap function in the drawBackground event and so far it seems to work:


def drawBackground(self, painter, rect):
if self.img:
painter.drawPixmap(rect, self.img, rect)

thanks for your help!

rbp
18th June 2008, 05:09
hmm..unfortunately it crashes in windows.

aamer4yu
18th June 2008, 05:22
What code are u using ? crash must be due some invalid pointer or something else

rbp
19th June 2008, 12:54
the thing is I'm using python which is supposed to take care of the memory management for me.
I've attached my little program if anyone feels motivated to take a look. To run it you need pyqt4 and PIL.

On Linux:
> python EyeEditor.py

and on Windows (if you have python and the other dependencies installed) you just double click EyeEditor.py

Then go File->Open and choose an image to view.
I traced it with a debugger on windows and found it crashed at line 23 of ZoomView.py where I try to display the image. But I have no problems on Linux, only Windows.

Any tips are very welcome!
Richard