almagest
20th December 2010, 13:21
Hello.
I am creating a grid (like a graph) from a QGraphicsView adding zooming capabilities.
If i use the scrollwheel on the graphicsview, the application zoomes the view as intended.
I now want to map a button to emit a QWheelEvent signal to the graphicsview widget.
(a zoom button)
the slot function for the buttons clicked() signal.
// slot function for the clicked() signal of the zoombutton
void DSATS::plusZoom()
{
std::cout << "should zoom" << std::endl;
QWheelEvent * event = new QWheelEvent(QPoint(10, 10), 120, Qt::LeftButton, Qt::NoModifier);
QApplication::postEvent(dsatsGrid, event);
}
Here dsatsGrid is a subclassed QGraphicsView.
// wheelevent handler in the grid-class
void GfxGrid::wheelEvent(QWheelEvent* event)
{
std::cout << "wheelevent recieved" << std::endl;
...
}
When i click the button, the function zoomPlus is called as expected, but the wheelevent never reaches its intended target.
I have tried with both postEvent and sendEvent, but it makes no difference. (although i know postEvent should be used because its thread safe and handles the memory)
Thank you for any help!
I am creating a grid (like a graph) from a QGraphicsView adding zooming capabilities.
If i use the scrollwheel on the graphicsview, the application zoomes the view as intended.
I now want to map a button to emit a QWheelEvent signal to the graphicsview widget.
(a zoom button)
the slot function for the buttons clicked() signal.
// slot function for the clicked() signal of the zoombutton
void DSATS::plusZoom()
{
std::cout << "should zoom" << std::endl;
QWheelEvent * event = new QWheelEvent(QPoint(10, 10), 120, Qt::LeftButton, Qt::NoModifier);
QApplication::postEvent(dsatsGrid, event);
}
Here dsatsGrid is a subclassed QGraphicsView.
// wheelevent handler in the grid-class
void GfxGrid::wheelEvent(QWheelEvent* event)
{
std::cout << "wheelevent recieved" << std::endl;
...
}
When i click the button, the function zoomPlus is called as expected, but the wheelevent never reaches its intended target.
I have tried with both postEvent and sendEvent, but it makes no difference. (although i know postEvent should be used because its thread safe and handles the memory)
Thank you for any help!