Results 1 to 2 of 2

Thread: Changing renderHints of QGraphicsView after object creation

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Posts
    79
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Changing renderHints of QGraphicsView after object creation

    Hi,

    I am new to QT programming (but I really like it :-)) and here is an issue I do not know how to solve:

    I would like to be able to switch the renderHint QPainter::SmotthPixmapTransform on and off dynamically.

    My custom QGraphicsItem looks like

    Qt Code:
    1. class MyItem : public QGraphicsItem
    2. {
    3. public:
    4. MyItem()
    5. {
    6. QGraphicsLineItem * top = new QGraphicsLineItem(...,this);
    7. QGraphicsLineItem * left = new QGraphicsLineItem(...,this);
    8. }
    9. void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
    10. {
    11. if(mouseaction_going_on)
    12. painter->setRenderHint(QPainter::SmoothPixmapTransform, false);
    13. else
    14. painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 
    But in practice, nothing happens, the rendering is performed with exactly those renderHints that have been specified at creation time of the QGraphicsView.

    What about the painter->save() and restore() functions? Might they help me?

    By the way, at whcih stage of the painting procedure is the painting of the child items of MyItem perfomed? Maybe the painting of them is already done when it comes to my setRenderHints()-calls.

    Thank you very much in advance for your great support!!!

    Best Regards,
    Oliver
    Last edited by olidem; 2nd March 2009 at 09:08. Reason: reformatted to look better

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.