Tepi
15th October 2009, 06:59
Hello everyone,
I'll start by explaining a little bit of background situation... so here's the deal.
I have a main window which shows multiple custom widgets, these are called services in my program. These services consists of multiple widgets, such as QSliders, QPushButtons etc. whatever widgets the services might want to show.
Here comes the problem:
I have a situation where some services might need to have keys binded to some specific operations, such as controlling a radio-controlled car (this is a real RC car). So I want to bind keys "w", "a", "s" and "d" for controls of the car. There's also some widgets (somekind of a meters or something similar) to display the throttle and steering information. These widgets should also react to the binded keys.
Problematic part here is that I might have multiple services which all might need keys, also same keys, binded to different things. So the determination of which service should get the keyPressEvents at some specific time is needed.
I have thought of using mouse to determine to which service keyPressEvents should go. It should work like so: if I have a mouse cursor over some service (or maybe if I have clicked mouse over the service) the keyPressEvents should go to that specific service. What do you think about this solution? Any other suggestions?
How can I implement this feature? I have tried of using setMouseTracking on those services and when the mouse is over some service it shows that services name as a tooltip. So somehow it is able to know the specific services which has the mouse over. Is there something like hasMouseOver() function on QWidget or QObject or some other class... Any ideas how to get keyEvents directed as I described above with the help of mouse?
And for the key bindings, should I reimplement the keyPressEvent or can I use QActions with some shortcut keys? Which one would you recommend?
Any help/ideas is/are greately appreciated.
Greetings,
-Tepi
I'll start by explaining a little bit of background situation... so here's the deal.
I have a main window which shows multiple custom widgets, these are called services in my program. These services consists of multiple widgets, such as QSliders, QPushButtons etc. whatever widgets the services might want to show.
Here comes the problem:
I have a situation where some services might need to have keys binded to some specific operations, such as controlling a radio-controlled car (this is a real RC car). So I want to bind keys "w", "a", "s" and "d" for controls of the car. There's also some widgets (somekind of a meters or something similar) to display the throttle and steering information. These widgets should also react to the binded keys.
Problematic part here is that I might have multiple services which all might need keys, also same keys, binded to different things. So the determination of which service should get the keyPressEvents at some specific time is needed.
I have thought of using mouse to determine to which service keyPressEvents should go. It should work like so: if I have a mouse cursor over some service (or maybe if I have clicked mouse over the service) the keyPressEvents should go to that specific service. What do you think about this solution? Any other suggestions?
How can I implement this feature? I have tried of using setMouseTracking on those services and when the mouse is over some service it shows that services name as a tooltip. So somehow it is able to know the specific services which has the mouse over. Is there something like hasMouseOver() function on QWidget or QObject or some other class... Any ideas how to get keyEvents directed as I described above with the help of mouse?
And for the key bindings, should I reimplement the keyPressEvent or can I use QActions with some shortcut keys? Which one would you recommend?
Any help/ideas is/are greately appreciated.
Greetings,
-Tepi