Results 1 to 3 of 3

Thread: QBrush TexturePattern alignment

  1. #1
    Join Date
    Mar 2006
    Posts
    142
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QBrush TexturePattern alignment

    Hello,
    I create a QBrush with a TexturePattern and set a pixmap like this:
    Qt Code:
    1. QPixmap pm("eye.png");
    2. this->brush = QBrush(pm);
    3. QRect r(100, 100, pm.width(), pm.height());
    4. painter.fillRect(r, this->brush);
    To copy to clipboard, switch view to plain text mode 
    The results is below, ie the image left corner is in the (about) middle of the QRect, so what did I miss?
    Attached Images Attached Images

  2. #2
    Join Date
    Nov 2008
    Location
    Oslo, Norway
    Posts
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QBrush TexturePattern alignment

    Are you sure you didn't mean for your QRect to be:
    Qt Code:
    1. QRect r(0, 0, pm.width(), pm.height());
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2006
    Posts
    142
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QBrush TexturePattern alignment

    Hmmmm, it turns out that it works!
    So let me try to understand how it works: the pixmap is actually mapped not on the QRect itself but rather on the whole canvas, in a tile manner, and the QRect acts as a window on this tiled canvas, right?
    So my question is now: how to map the pixmap on the QRect, whatever location this QRect is drawn at?

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.