Results 1 to 7 of 7

Thread: QBrush pixmap tiling

  1. #1
    Join Date
    May 2008
    Location
    Melbourne, Australia
    Posts
    136
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QBrush pixmap tiling

    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

  2. #2
    Join Date
    May 2008
    Location
    Melbourne, Australia
    Posts
    136
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QBrush pixmap tiling

    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?

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QBrush pixmap tiling

    what are you using the brush on ?? QWidget ?
    You can simple use QPainter::drawPixmap to draw the Pixmap.

  4. #4
    Join Date
    May 2008
    Location
    Melbourne, Australia
    Posts
    136
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QBrush pixmap tiling

    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:
    Qt Code:
    1. def drawBackground(self, painter, rect):
    2. if self.img:
    3. painter.drawPixmap(rect, self.img, rect)
    To copy to clipboard, switch view to plain text mode 

    thanks for your help!

  5. #5
    Join Date
    May 2008
    Location
    Melbourne, Australia
    Posts
    136
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QBrush pixmap tiling

    hmm..unfortunately it crashes in windows.

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QBrush pixmap tiling

    What code are u using ? crash must be due some invalid pointer or something else

  7. #7
    Join Date
    May 2008
    Location
    Melbourne, Australia
    Posts
    136
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QBrush pixmap tiling

    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
    Attached Files Attached Files

Similar Threads

  1. finding maximum scaling of a pixmap
    By babu198649 in forum Newbie
    Replies: 1
    Last Post: 31st March 2008, 14:32
  2. empty pixmap as a QLabel
    By tommy in forum Qt Programming
    Replies: 16
    Last Post: 11th December 2007, 21:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.