Results 1 to 6 of 6

Thread: ScrollBar

  1. #1
    Join Date
    Oct 2011
    Posts
    48
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default ScrollBar

    Hai all,



    If i don't want to scroll the contents of scrollarea by scrolling mousewheel and i want to scroll the contents of scrollarea only by dragging the slider of scrollarea , how can i do that?



    Thanks.

  2. #2
    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: ScrollBar

    Subclass the scrollarea and reimp QAbstractScrollArea::wheelEvent() that it does nothing, or install an event filter, that eats the mouse wheel event.

  3. #3
    Join Date
    Oct 2011
    Posts
    48
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: ScrollBar

    Hai,

    Thanks Lykurg for your reply.I have installed eventfilter for mousewheel. But still the contents are scrolled when I scroll the mousewheel.Why so?Am I doing anything wrong?

    bool MainWindow::eventFilter(QObject *obj, QEvent *event)
    {

    if (obj == ui->scrollArea)
    {
    if (event->type() == QEvent::Wheel)
    {

    return true;
    }
    else
    {
    return false;
    }
    }
    else
    {
    return QMainWindow::eventFilter(obj, event);
    }

    }




    Thanks.

  4. #4
    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: ScrollBar

    Hi, I can't try it right now, but also try to use the viewport of the scroll view: QAbstractScrollArea::viewport(). Also see if the event filter is actually called.

  5. #5
    Join Date
    Oct 2011
    Posts
    48
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: ScrollBar

    Hi,

    Yes, i have called eventfilter in constuctor of class .


    ui->scrollArea->installEventFilter(this);


    Now I will try viewport as you said.


    Thanks

  6. #6
    Join Date
    Oct 2011
    Posts
    48
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: ScrollBar

    What I want to do is , I have an Image in scrollarea . I dont want to scroll the contents using mousewheel.Instead I want to zoom the image to the mouse point by mousewheel.So i thought to adjust the scrollbar position according to the mouse point.For that I need to disable the scrolling option.But I want scrollbars too. How can I do this?

Similar Threads

  1. Scrollbar code
    By bobmanc in forum Qt Quick
    Replies: 4
    Last Post: 23rd April 2011, 16:55
  2. How to add scrollbar...?
    By jojanpm in forum Qt Programming
    Replies: 4
    Last Post: 25th October 2010, 19:51
  3. ScrollBar
    By damodharan in forum Qt Programming
    Replies: 1
    Last Post: 11th February 2010, 15:50
  4. Scrollbar on the left
    By torn in forum Qt Programming
    Replies: 5
    Last Post: 14th September 2009, 10:22
  5. Scrollbar
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 31st October 2007, 08:33

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.