Results 1 to 2 of 2

Thread: QGraphicsView and scrollbars

  1. #1
    Join Date
    Mar 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QGraphicsView and scrollbars

    Hello,

    I'm using a QGraphicsView widget for the texture browser I'm currently coding. I load a big image file with a lot of textures on it and then do lots of stuff to it.
    Now the problem is I want to display all of the image in the horizontal direction. For example: if the size of the image is 256x512 I want my QGraphicsview to have a width of 256.

    For now, let's say the image width is always going to be 256 and I set it to that manually. When the image height is large, a vertical scrollbar is going to appear, but then the viewable area of the widget is not 256 anymore and I can't see the whole image in the horizontal direction.

    How can I solve this?
    Jeroen

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QGraphicsView and scrollbars

    Either
    • subclass QScrollBar and reimplement QWidget::showEvent() and QWidget::hideEvent()
    • subclass QScrollBar and reimplement QWidget::setVisible()
    • use an event filter to catch show/hide events

    react to visibility changes and make the view larger/smaller when needed.
    J-P Nurmi

Similar Threads

  1. Problem determining size of QGraphicsView
    By Bocki in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2008, 14:54
  2. QEvent for QGraphicsView scrollbars?
    By forrestfsu in forum Qt Programming
    Replies: 9
    Last Post: 2nd December 2006, 07:42
  3. How to disable wheelEvent for scrollbars
    By forrestfsu in forum Qt Programming
    Replies: 7
    Last Post: 11th October 2006, 19:05

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.