Results 1 to 6 of 6

Thread: matrix for QBrush

  1. #1
    Join Date
    Aug 2008
    Posts
    134
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default matrix for QBrush

    Hi,
    I am creating re-sizable nodes(QFraphicsItem) for some shapes(QgraphicsItem). While zooming i doesn't want nodes to be zoomed in shapes but the node's co-transformation should be applied. I have read the comment in http://www.qtcentre.org/threads/1395...hics-view-item, where i can resolve this by apllying the inverted matrix of painter instance to QBrush instance. but in my program brush matrix is not combined with painter instance. I am using Qt 4.4. Is this is a bug.

    http://www.qtcentre.org/threads/1395...hics-view-item

    Thanks

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: matrix for QBrush

    It would help if you provided some source code of your painting. Or are we supposed to guess, what went wrong?

  3. #3
    Join Date
    Aug 2008
    Posts
    134
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: matrix for QBrush

    Please find the attachment. i have attached the whole project and the snapshot of problem. I have developed using QT 4.4 and VS 2008Attachment 4246
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by navi1084; 5th February 2010 at 05:34.

  4. #4
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: matrix for QBrush

    The brush-matrix affects stuff like the stippling pattern of the brush. But it can't affect the polygon-coordinates of your handles, which are transformed by the painters scaling..

    I would approach your problem from a different angle:

    Make your CHandleItem a QGraphicsItem subclass. (Not a QGraphicsPolygonItem whose polygon features you are not even using..).

    Use setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
    That will transform the items coordinates right, but won't scale or shear it.

    In your updateHandle() method, specify the Position of the handles, and do the actual drawing of the 5x5 handle in the paint method.

    HIH

    Johannes

  5. The following user says thank you to JohannesMunk for this useful post:

    navi1084 (5th February 2010)

  6. #5
    Join Date
    Aug 2008
    Posts
    134
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: matrix for QBrush

    Thanks for the reply. I will implement ur suggestion and let you know.

  7. #6
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: matrix for QBrush

    Allright! Make sure you specify the item's position through QGraphicsItem::setPos, so that the QGraphicsScene can do its magic.

    In the paint method you then just need to draw a rectangle of your handlesize around the items center: 0/0.

    Johannes

Similar Threads

  1. QBrush pattern problem
    By ilovethisgame in forum Qt Programming
    Replies: 2
    Last Post: 4th October 2012, 22:07
  2. Any suggestions of Matrix library with Qt?
    By Sheng in forum Qt Programming
    Replies: 3
    Last Post: 5th February 2010, 03:48
  3. Is there any API to set QBrush instance as Cosmetic
    By navi1084 in forum Qt Programming
    Replies: 6
    Last Post: 3rd February 2010, 03:47
  4. Dot Matrix Printer
    By estanisgeyer in forum Qt Programming
    Replies: 3
    Last Post: 18th December 2009, 19:30
  5. Diff between QBrush and QPen
    By wagmare in forum Qt Programming
    Replies: 5
    Last Post: 16th February 2009, 14:47

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.