PDA

View Full Version : Propagating event to scrollBar



bunjee
22nd June 2008, 14:16
I'm trying to propagate an event to my QScrollbar.


/* virtual */ void ZeContactFlow::wheelEvent(QWheelEvent * event)
{
std::cout << "Hello ?\n";
if (mScrollBar)
{
QWheelEvent * newEvent = new
QWheelEvent(event->pos(), event->globalPos(), event->delta(), event->buttons(),
Qt::NoModifier, event->orientation());
QCoreApplication::postEvent(mScrollBar, newEvent);
}
}

This code has no effect. What am I doing wrong ?

jpn
22nd June 2008, 18:23
So ZeContactFlow is something which doesn't inherit QAbstractScrollArea (which already does such thing)?

bunjee
22nd June 2008, 18:30
QAbstractScrollArea instance is a child of ZeContactFlow instance.

bunjee
23rd June 2008, 19:56
/* virtual */ void ZeContactFlow::wheelEvent(QWheelEvent * event)
{
std::cout << "Hello ?\n";
if (mScrollBar)
{
//QWheelEvent * newEvent = new
// QWheelEvent(event->pos(), event->globalPos(), event->delta(), event->buttons(),
// Qt::NoModifier, event->orientation());
QApplication::sendEvent(mScrollBar, event);
}
else
{
event->ignore();
}
}

This implementation makes me crash