Results 1 to 4 of 4

Thread: Qt QGraphicsView - BackgroundBrush Translate

  1. #1

    Default Qt QGraphicsView - BackgroundBrush Translate

    I have created a view class derived from QGraphicsView and set the backgroundBrush as an image.
    I want to translate the backgroundBrush. I have tried the following

    Qt Code:
    1. // graphicsView derived from QGraphicsView
    2. graphicsView->backgroundBrush().transform().translate(moveX, moveY);
    To copy to clipboard, switch view to plain text mode 

    But it is not transforming the background brush.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt QGraphicsView - BackgroundBrush Translate

    QGraphicsView::backgroundBrush() returns a copy of the view's background brush.

    You modify the copy, letting the brush used by the view stay unchanged.
    See QGraphicsView::setBackgroundBrush() for applying a changed brush.

    Cheers,
    _

  3. #3

    Default Re: Qt QGraphicsView - BackgroundBrush Translate

    Thanks for the reply. I have tried the following in the timer update

    Qt Code:
    1. tx += 0.2f;
    2. ty += 0.5f;
    3.  
    4. m_BackgroundBrush = graphicsView->backgroundBrush();
    5. m_BackgroundBrush.transform().translate(tx, ty);
    6. graphicsView->setBackgroundBrush(m_BackgroundBrush);
    To copy to clipboard, switch view to plain text mode 

    But the background brush is not moving.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt QGraphicsView - BackgroundBrush Translate

    Now you are modifying a copy of the QTransform object of QBrush.

    Cheers,
    _

Similar Threads

  1. unable to translate QGraphicsView
    By sven-kt in forum Qt Programming
    Replies: 4
    Last Post: 18th January 2010, 17:42
  2. translate on fly
    By Noxxik in forum Qt Programming
    Replies: 5
    Last Post: 26th February 2009, 15:21
  3. QGraphicsView::translate
    By chaoticbob in forum Qt Programming
    Replies: 4
    Last Post: 30th November 2008, 11:30
  4. QGraphicsView::translate
    By peace_comp in forum Qt Programming
    Replies: 4
    Last Post: 7th April 2008, 11:59
  5. QListView & backgroundBrush -> Houston we hv a problem
    By travis in forum Qt Programming
    Replies: 3
    Last Post: 31st July 2006, 08:13

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.