Results 1 to 4 of 4

Thread: QGraphicsView::fitInView()

  1. #1
    Join Date
    Jul 2008
    Location
    Munich
    Posts
    73
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsView::fitInView()

    Anybody knows the implied difference between these pieces of code? Any duplicated updating?
    Thanks.

    Qt Code:
    1. void my_graphicsView::resizeEvent(QResizeEvent *event)
    2. {
    3. setWidth(event->size().width());
    4. setHeight(event->size().height());
    5.  
    6. fitInView(QRectF(0,0,width(),height()),Qt::KeepAsp ectRatioByExpanding);
    7. arrangeNodes();
    8.  
    9. m_scene->setSceneRect(0,0,width(),height());
    10. this->setSceneRect(0,0,width(),height());
    11.  
    12. update();
    13. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void my_graphicsView::resizeEvent(QResizeEvent *event)
    2. {
    3. setWidth(event->size().width());
    4. setHeight(event->size().height());
    5.  
    6. fitInView(QRectF(0,0,width(),height()),Qt::KeepAsp ectRatioByExpanding);
    7. arrangeNodes();
    8.  
    9. m_scene->update(0,0,width(),height());
    10. update();
    11. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by high_flyer; 30th March 2011 at 14:26.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView::fitInView()

    Is this home work?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jul 2008
    Location
    Munich
    Posts
    73
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsView::fitInView()

    Quote Originally Posted by high_flyer View Post
    Is this home work?
    fitInView() works.

    But it I comment it out, the paiting quality seems to be lower.

    In QGraphicsItem's paint(), I have:

    Qt Code:
    1. painter->setRenderHint(QPainter::SmoothPixmapTransform);
    2. painter->setPen(QPen(Qt::red));
    3. painter->setBrush(QBrush(Qt::gray, Qt::Dense4Pattern));
    To copy to clipboard, switch view to plain text mode 

    Actually there is another post which is related to my problem:
    http://www.qtcentre.org/threads/4013...gging-blinking

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView::fitInView()

    fitInView() works.

    But it I comment it out, the paiting quality seems to be lower.
    Well it might for example, if the fitInView() has to cause scaling up for the drawn elements.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. graphicsView.fitInView() :- one axis only ?
    By JackDinn in forum Newbie
    Replies: 6
    Last Post: 21st February 2011, 22:24
  2. QGraphicsView::fitInView() problem on Windows
    By nileshsince1980 in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2009, 04:52
  3. How to don't fitInView a QGraphicsItem
    By jano_alex_es in forum Newbie
    Replies: 2
    Last Post: 26th October 2009, 14:52
  4. fitInView problem at QGraphicsView
    By oguzy in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2008, 23:36
  5. graphics view FitInView problem
    By aamer4yu in forum Qt Programming
    Replies: 6
    Last Post: 25th January 2007, 10:24

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.