Results 1 to 3 of 3

Thread: QGraphicsView scale function

  1. #1
    Join Date
    Oct 2006
    Posts
    83
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QGraphicsView scale function

    I'm currently using graphicsview to simulate zooming in/out on an image. Zooming in seems to be perfect, but when I zoom out passed the original size of the graphicsview it begins to tile the images. I only want one image to show up...not tiled. Is there any ideas on the best way about trying to solve this problem?

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

    Default Re: QGraphicsView scale function

    Hard to tell without seeing your code. Maybe you're instantiating many items instead of one?

  3. #3
    Join Date
    Oct 2006
    Posts
    83
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsView scale function

    Below is basicaly what my code is for that particular part.

    Qt Code:
    1. scene = new QGraphicsScene;
    2. scene->setSceneRect(0, 0, 512, 640);
    3. scene->setItemIndexMethod(QGraphicsScene::NoIndex);
    4. ui.graphicsView->setScene(&*scene);
    5.  
    6. void Form::scaleView(qreal scaleFactor)
    7. {
    8. ui.graphicsView->scale(scaleFactor, scaleFactor);
    9. }
    10.  
    11. bool Form::eventFilter(QObject *o, QEvent *e)
    12. {
    13. if (0 == ui.graphicsView->viewport()){
    14. if (e->type() == QEvent::Wheel)
    15. {
    16. QWheelEvent *q = dynamic_cast<QWheelEvent*>(e);
    17. scaleView(pow((double)2, -q->delta() / 240.0));
    18. e->accept();
    19. return true;
    20. }
    21. }
    22. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by forrestfsu; 12th October 2006 at 14:19.

Similar Threads

  1. Link Errors
    By magikalpnoi in forum Qt Programming
    Replies: 5
    Last Post: 25th September 2006, 22:04
  2. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52
  3. Qt 4.1.4 plugin QPSQL
    By jcr in forum Installation and Deployment
    Replies: 4
    Last Post: 22nd June 2006, 22:55
  4. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52
  5. Replies: 25
    Last Post: 15th January 2006, 00:53

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.