View Full Version : ScrollBar
A9am
5th November 2011, 11:21
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.
Lykurg
5th November 2011, 14:06
Subclass the scrollarea and reimp QAbstractScrollArea::wheelEvent() that it does nothing, or install an event filter, that eats the mouse wheel event.
A9am
7th November 2011, 06:39
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.
Lykurg
7th November 2011, 07:48
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.
A9am
7th November 2011, 07:51
Hi,
Yes, i have called eventfilter in constuctor of class .
ui->scrollArea->installEventFilter(this);
Now I will try viewport as you said.
Thanks
A9am
8th November 2011, 06:23
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?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.