Results 1 to 5 of 5

Thread: QGraphicsView scroll bars disappears

  1. #1
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default QGraphicsView scroll bars disappears

    Hi,

    in my scene I use to have a lot of removable items, so most of times the scene is bigger than expected, way more sometimes.

    I want to solve this by updating, by code, its size qhen the user presses a button.

    I'm doing:
    Qt Code:
    1. QRectF itemRec = m_pSkScene->itemsBoundingRect();
    2. m_pSkScene->setSceneRect(itemRec);
    3. //m_pSkScene.views().at(0)->setSceneRect(itemRec);
    4. ui.graphicsView->setSceneRect(itemRec);
    To copy to clipboard, switch view to plain text mode 

    it resizes right, but when an item goes out the scroll bar doesn't appears as before. Setting "scrollBarAlwaysOn" doesn't solve it.

    any idea? thanks!

  2. #2
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: QGraphicsView scroll bars disappears

    Some images:

    first of all, the scene has few graphicsItems, and it's too large




    So the code is executed, in order to make it smaller.




    But, the scroll bar are disabled... and they don't enable even if I move an item outside the view.




    Seems like I forgot something basic... but I don't know what :S

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QGraphicsView scroll bars disappears

    Try not to set the scene rect by using the view. Only use QGraphicsScene::setSceneRect(). And did you draw the arrows outside the bounding rect of the items?

  4. #4
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: QGraphicsView scroll bars disappears

    Try not to set the scene rect by using the view
    I'm trying with both, and with both at the same time as well and it's the same.


    And did you draw the arrows outside the bounding rect of the items?
    Yes, actually I can even move them. I can also create, by code, new items outside the viewport but only access to them if I resize the view manually.

    Is it, for any chance, the expected behavior?

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QGraphicsView scroll bars disappears

    Quote Originally Posted by jano_alex_es View Post
    Yes, actually I can even move them. I can also create, by code, new items outside the viewport but only access to them if I resize the view manually.
    You didn't get me right. Did you draw the arrows yourself in the paint method of a subclassed item? If so, make sure, you respect the bounding rect of that item, that you don't draw outside.

    Anyway, can you make a minimal compilable example reproducing your problem.

Similar Threads

  1. scroll bars are not appearing
    By Cruz in forum Qt Programming
    Replies: 4
    Last Post: 10th September 2010, 18:26
  2. Replies: 0
    Last Post: 19th November 2009, 19:19
  3. Enabling scroll bars in disabled QTableView
    By Koas in forum Qt Programming
    Replies: 2
    Last Post: 9th October 2009, 11:39
  4. Replies: 1
    Last Post: 11th June 2009, 06:49
  5. QScrollArea's Scroll Bars
    By ToddAtWSU in forum Qt Programming
    Replies: 5
    Last Post: 19th September 2006, 14:27

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.