Hi you all Qt experts of the world.
I have some experience in Qt yet but all is self instructed. So far I always succeeded to find all I needed in the very extensive Qt library and I am very happy. But now for the first time I am caught in a small hitch that I thought some more experienced programmers could help me with.
I Use Qt embedded under linux on an ARM with a touch screen.
Situation:
I want to create a scroll list that is scrollable with the finger, like the songs list of an Iphone or Ipod touch. I use Graphics View framework.
Each entry of my list is a custom object derived from QGraphicsItem. So far so good. I already implemented everything with a button to scroll up and down and it works fine. Now I want to change it for finger scrolling. If you click on an item of the list it sends a message to play a song.
What I did:
I created my own QGraphicsWidget derived widget that is invisible but covers the scrollable area of the screen, it's called CMouseScrollerWidget. This widget was programmed to catch mouse events, manage the scrolling and forward the position of the mouse (in scroll mode) to the parent item so it can then scroll the list. That works.
What is the problem:
My problem appears when the user only click-and-release an item of the list to select it (to start a song for instance). What happens is that the CMouseScrollerWidget grabs the mouse because it's got no other choice. If the user releases without moving the mouse there is no way for the list item widget to receive the MouseReleasedEvent because the mouse is grabbed by CMouseScrollerWidget. I tried a lot of things and even if I call ignore() there is no way of propagating the MouseReleaseEvent to the other widget under the mouse.
Now:
I know that I could implement a signal that would be monitored by all the items in the list and notify them when the mouse is only clicked. Then each item shall check if the mouse pointer is pointing on themselves and this is not very efficient.
I could also notify the parent which could call QGraphicsScene::items(QPoint) and parse the list to find the good item and notify it. Again, I think this is not very efficient because I would have to implement an identification mechanism for my graphics items so that the parent is shure it is pointing to the list item and not the background image widget...
Another solution that I thought of would be for the parent to parse the list of list items widget and find the item that is at the click point... again not very efficient since Qt does this very well (and kind of already did when the user clicked the mouse)
What I'm looking for:
Is there a way of using the very efficient object-finding feature of Qt. My best bet would be to be able to ignore() the MouseReleaseEvent so it is directly propagated to the exact good item. That is what I think would be the most efficient scheme but mouse grabbing mechanism is not permitting this behavior.
If it's not possible, is there some other kind of way to notify visible objects under the mouse only ?
Thank you all, it was a long question but I thought giving more details would help having a precise answer !
J-F
Bookmarks