Results 1 to 4 of 4

Thread: QGraphicsView and QScrollBar

  1. #1
    Join Date
    Oct 2009
    Posts
    70

    Default QGraphicsView and QScrollBar

    Hi...

    I've a QGraphicsView and I've set a custom scroll bar with setVerticalScrollBar().
    It change the default scrollbar but I've two problem:

    1) If I try to resize this scroll bar more than the default..half of it is hidden. I've tryed with many solution but I can't see all the new scroll bar.

    2) Does anybody know a way to make it possible that If a user press with the mouse (and not whit keyboard PagDown or arrow keys) a scroll bar...this scroll bar can slide with a predefinite minimum value (and not for all the value of the slider)??!!

    I want to make the same about press the Page Down key (set whit setSingleStep()) and the mouse that grab the scroll bar.

    Thanks

  2. #2
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView and QScrollBar

    It is hard work to replace the scrollbar since you have to respond to events and manage not only position, but the viewport size of your view.

    Why do you want to replace the default one?

    If you want to change its behaviour, you can always disable it and add additionnal widgets that control your graphics view using QGraphicsView::centerOn and QGraphicsView::fitInView

  3. #3
    Join Date
    Oct 2009
    Posts
    70

    Default Re: QGraphicsView and QScrollBar

    Many thanks!! For the first question I've solved with the style sheet....

    About the second question...does anybody tella a solution?

    I want that when I drag with the mouse a scroll bar...this scroll bar doesn't move 1 to 1 but with a minimum size....

    I hope that my issue is clear...

    thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 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 and QScrollBar

    Quote Originally Posted by paolom View Post
    1) If I try to resize this scroll bar more than the default..half of it is hidden. I've tryed with many solution but I can't see all the new scroll bar.
    You need to use QAbstractScrollArea::setViewportMargins() to inform the widget about new margins it should leave for your scrollbar.

    2) Does anybody know a way to make it possible that If a user press with the mouse (and not whit keyboard PagDown or arrow keys) a scroll bar...this scroll bar can slide with a predefinite minimum value (and not for all the value of the slider)??!!
    Override mousePressEvent().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Can not cast into the derived class from QScrollBar
    By learning_qt in forum Qt Programming
    Replies: 2
    Last Post: 19th December 2008, 10:23
  2. Custom scrolling of QGraphicsView
    By hb in forum Qt Programming
    Replies: 0
    Last Post: 12th August 2008, 10:10
  3. QGraphicsView scrolling problem with 4.3.0
    By hb in forum Qt Programming
    Replies: 8
    Last Post: 30th August 2007, 22:18

Tags for this Thread

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.