Results 1 to 7 of 7

Thread: Is there any API to set QBrush instance as Cosmetic

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

    Default Is there any API to set QBrush instance as Cosmetic

    Hi,
    I have created a application which contains different shapes of QGraphicsItem with resizable handles/thumbs (derived from QGraphicsItem). I want only shapes to be zoom in/out. For that reason i made shapes pen as cosmetic which restrict the thickness of the pen to be changed.
    Even i want shape's thumbs to be fixed in size even though it is zoomed in/out(same like cosmetic pen), but transformation should be applied i.e thumbs should be placed respective co-ordinates as per the zoom factor.
    Is there anyway to make QBrush as cosmetic i.e restricting the shape to be in same size.

    Thanks

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

    Default Re: Is there any API to set QBrush instance as Cosmetic

    is there any way??? Please....


    Thanks

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Is there any API to set QBrush instance as Cosmetic

    For custom items when you do your own painting you should be able to adjust the brush based on the item transformation manually (i.e. reverse the transformation made by the scene). An alternative is to set the item to ignore transformations and implement zooming manually (by changing the size of the item).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Unhappy Re: Is there any API to set QBrush instance as Cosmetic

    Thank you for the reply.

    After your comment (reverse the transformation made by the scene) I am using following set of code in derived class of QGraphicsPolygonItem():

    void Handle:aint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
    {
    Q_UNUSED(widget);
    m_Brush.setMatrix(painter->matrix().inverted());
    painter->setBrush(m_Brush);
    painter->setPen(m_Pen);
    painter->drawPolygon(m_Palygon);

    }

    The instance of Handle is child of another shape which is used for resizing. Hence parent's matrix will be applied here too. I cant use "ItemIgnoresTransformations". By applying the inverse of painter matrix to QBrush my problem is not resolving.

    Is this is the way you suggested?

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

    Default Re: Is there any API to set QBrush instance as Cosmetic

    I saw a post in Qt center(http://www.qtcentre.org/threads/1395...hics-view-item) which tell about the bug in brush matrix. But i am using QT 4.4, still unable to resolve the fix.

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

    Default Re: Is there any API to set QBrush instance as Cosmetic[BUG?]

    I am using QT commercial edition 4.4. Whatever matrix i am applying for QBrush is ignored by the painter.. Is this is a bug??

    Thanks

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

    Default Re: Is there any API to set QBrush instance as Cosmetic[BUG?]

    Can anyone tell whether this issue is a bug? or is there any way to resolve this?

Similar Threads

  1. Replies: 9
    Last Post: 13th June 2012, 15:42
  2. Incorrect drawing of non cosmetic line
    By Amargedon in forum Qt Programming
    Replies: 5
    Last Post: 16th July 2009, 17:50
  3. QBrush TexturePattern alignment
    By Caius Aérobus in forum Qt Programming
    Replies: 2
    Last Post: 23rd November 2008, 14:41
  4. QBrush pixmap tiling
    By rbp in forum Qt Programming
    Replies: 6
    Last Post: 19th June 2008, 12:54
  5. QBrush texture pattern
    By edb in forum Qt Programming
    Replies: 4
    Last Post: 17th April 2007, 13:18

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.