Problem with horizontal wheelEvent
-
I have implemented wheelEvent method in a QMainWindow class and when there's a vertical wheelEvent it's being called correctly, but when the wheelEvent is horizontal it's never called. I'm using a laptop and when there's a wheelEvent it's horizontal or vertical I can see how the mouse cursor icon changes so I'm sure there's a wheelEvent, but the method is never called when it's horizontal.
-
Hi Sheenmue,
The wheelEvent is called in both cases. You can check that by using e.g. qDebug () and QWheelEvent::orientation() inside wheelEvent method.
-
I'm already checking it, but nothing happens. This is the code:
@void MainWindow::wheelEvent(QWheelEvent event){
qDebug() << "WheelEvent";
int mouseDegrees = -1event->delta()/8;
if(event->orientation() == Qt::Horizontal){
int canal = (currentY+event->pos().y()-HEADER)/(CHANNEL_MARGIN+CHANNEL_TOP+ITEM_MARGIN+ITEM_H+CHANNEL_BOTTOM);
qDebug() << "Canal " << canal;
if(canal<channels->count() && canal >= 0){
channels->at(canal)->finalX += mouseDegrees4;
if(!timer->isActive()){
timer->start(TIMER);
}
}
}else{
finalY += mouseDegrees4;
if(!timer->isActive()){
timer->start(TIMER);
}
}
}@ -
This is not a matter of wheelEvent code but how do you try to call it. Do you have any widgets (children) on top of MainWindow ? Do you really scroll horizontally ? How ?
-
As I said I simply implemented the method in a class that inherits from QMainWindow. Some widgets are shown sometimes and when they are wheelEvent is never called (horizontal nor vertical), but that's normal. The problem is just that horizontal wheel events are never detected and as I said I know I'm making them correctly because the mouse cursor icon changes in my laptop and it works with web browsers.
I have uploaded the program in its current state. If somebody wants to try it to see if it's a problem with my laptop it can be downloaded from "here":http://www.fallenleafsoft.com/Horus.rar . It hasn't install files or anything else, just run Horus.exe and if you want to delete it simply delete the folder, it should run in Windows. The app is an rss reader.
-
Could you put here the simple example that reproduces you problem ?
I tried on my workstation with the simple example and it works fine. -
I received a new iMac, tried the program compiled for both Windows 7 and Mac OS X Lion and it worked perfectly with the magic mouse so it was a problem with my laptop, for some reason it doesn't work with its touchpad even if horizontal scroll works with other programs. If somebody experiences the same problem it's an Acer Aspire with a Synaptics touchpad.