Results 1 to 3 of 3

Thread: QGraphicsScene and View scrolling problem

  1. #1
    Join Date
    Mar 2010
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QGraphicsScene and View scrolling problem

    Hi,
    I have a little problem with my QGraphicsView and QGraphicsScene when im scrolling. As you can see on pictures linked below i cliked this button to add Graph and some arrays, but something strange happened when i scrolling.

    At top i see only Graph, to see arrays i must scroll down and i dont know why, it is possible to have this arrays all the time?

    Pics to better understand my problem (only thing i did is changed scrollbar position)
    http://img16.imageshack.us/img16/6522/screen1ard.png
    http://img706.imageshack.us/img706/2315/screen2mr.png
    http://img21.imageshack.us/img21/74/screen3tw.png

    When im adding new items(graph or arrays) i simple resize QGraphicsScene (setSceneRectF) to oldsize+newitem.heigh and change newitem pos (setPos) to right place. It seems working only for 700px height i think, to see other i need to scroll down.

    I add QGraphicsView into layout and then into centralWidget in mainwindow which i set to Qt::WindowMaximized so i think this might be a problem, how can i expand view to all visible area?

    regards,
    ithinkso

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QGraphicsScene and View scrolling problem

    When im adding new items(graph or arrays) i simple resize QGraphicsScene (setSceneRectF) to oldsize+newitem.heigh and change newitem pos (setPos) to right place. It seems working only for 700px height i think, to see other i need to scroll down.
    Not sure why you are setting the size of the scene, scene rectangle will automatically grows when items are added to or moved in the scene, setting it explicitly will restrict the view to show the area set (which I guess is a problem in your case)

    I add QGraphicsView into layout and then into centralWidget in mainwindow which i set to Qt::WindowMaximized so i think this might be a problem, how can i expand view to all visible area?
    If the view placed in a layout, and layout is set on to a widget, and widget is set as a central widget on the QMainWindow, then the view will automatically fit to all the available area on the main window.

  3. #3
    Join Date
    Mar 2010
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsScene and View scrolling problem

    Thanks for reply, i figured out whats wrong except for you said, i was returning wrong boundingRect when i reimplemented this function for my graphicsitem classes and everythings works unexpected.

    Problem solved, ty one more time.

Similar Threads

  1. Replies: 1
    Last Post: 15th March 2010, 08:51
  2. items in view would disappear on scrolling
    By sepehr in forum Qt Programming
    Replies: 4
    Last Post: 21st March 2009, 07:20
  3. Scrolling problem with background using View/Scene
    By nileshsince1980 in forum Qt Programming
    Replies: 5
    Last Post: 22nd October 2007, 08:19
  4. How did I disable auto-scrolling function in tree-view
    By alfa_wu in forum Qt Programming
    Replies: 1
    Last Post: 28th September 2007, 08:31
  5. Replies: 4
    Last Post: 25th April 2007, 16:54

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.