Results 1 to 4 of 4

Thread: Two Brush styles for single rectitem

  1. #1
    Join Date
    Aug 2011
    Location
    bangalore
    Posts
    14
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Two Brush styles for single rectitem

    hi,can some one please tell me i just want my QGraphicsRectItems background should be blue color and top of that one i want the "BDiagPattern"..with my code i am getting only pattern inside the rectitem i want color also ...plese tell me how to do it?

    Qt Code:
    1. QBrush brush;
    2. brush.setStyle(Qt::BDiagPattern);
    3. QMatrix myMatrix(99,0,99,0,0,0);
    4. brush.setMatrix(myMatrix);
    5. foreach(QGraphicsItem *item ,Parentrect->childItems())
    6. {
    7. qgraphicsitem_cast <QGraphicsRectItem * >(item)->setBrush (Qt::blue));
    8. qgraphicsitem_cast <QGraphicsRectItem * >(item)->setBrush (brush);
    9. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Two Brush styles for single rectitem

    Qt Code:
    1. QBrush brush(Qt::blue, Qt::BDiagPattern);
    2. brush.setMatrix(QMatrix().scale(99,99));
    3. foreach(QGraphicsItem *item ,Parentrect->childItems())
    4. qgraphicsitem_cast <QGraphicsRectItem * >(item)->setBrush (Qt::blue));
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Aug 2011
    Location
    bangalore
    Posts
    14
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Two Brush styles for single rectitem

    sorry Marek, it showing only blue color .pattern is not displaying

  4. #4
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Two Brush styles for single rectitem

    It's not supported out of a box.

    Subclass QAbstractGraphicsShapeItem or QGraphicsRectItem and reimplement paint().
    Rememebr to change composition mode when drawing using second brush.

Similar Threads

  1. applying styles to single QAction
    By htroyo in forum Qt Programming
    Replies: 7
    Last Post: 1st May 2011, 01:17
  2. Replies: 8
    Last Post: 15th November 2010, 10:07
  3. View,Scene and RectItem
    By salmanmanekia in forum Newbie
    Replies: 2
    Last Post: 29th March 2010, 14:31
  4. Different text styles in a single cell of QTableView?
    By xfurrier in forum Qt Programming
    Replies: 2
    Last Post: 23rd August 2009, 06:49
  5. QPalette::brush
    By tpf80 in forum Newbie
    Replies: 6
    Last Post: 17th July 2007, 23:23

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.