PDA

View Full Version : Why so few slots?



hakermania
8th April 2011, 14:16
Hello all!
I was wondering why there are so few slots connected to widgets.
For example the pushbutton has on_released, on_clicked, on_pressed etc, but it's missing so many slots (that I personally don't use but...) like on_mouse_over, while_is_clicked etc...
This came to my mind while trying to create a small program that while you have pressed a button, the value of a slider changes and when you release the pushbutton then the slider stops. So, I searched for a slot something like while_it_is_clicked() but there wasn't any, and, finally I created a QTimer that was starting at pressed() and stopped at released().

So, the conclusion maybe, is that there aren't these slots because are easily developed by the user, using the already existing?

Zlatomir
8th April 2011, 14:28
I don't see a problem here, the framework provide the basic and the programmer can build on top of that if needed.

Anyway think about the documentation for all the stuff, i bet you don't want the documentation page for QPushButton to be as long as Stroustrup's book about The C++ programming language, we usually want just a simple button, and the ways to add functionality on top of it when we need that and Qt is very good with that.

wysota
8th April 2011, 14:48
For example the pushbutton has on_released, on_clicked, on_pressed etc, but it's missing so many slots (that I personally don't use but...) like on_mouse_over, while_is_clicked etc...
Signals and slots are a high-level semantic mechanism. What you're after is a low-level syntactic mechanism which is implemented by events. "Mouse being over me" is not in a regular interest of a button. Buttons are objects that "can be clicked", not those that "mice can hover over" and thus you have a "clicked" signal but not a "mouseOver" signal. You do however get a enterEvent().


This came to my mind while trying to create a small program that while you have pressed a button, the value of a slider changes and when you release the pushbutton then the slider stops. So, I searched for a slot something like while_it_is_clicked() but there wasn't any, and, finally I created a QTimer that was starting at pressed() and stopped at released().
Maybe you were searching in a wrong place then? There is a QAbstractButton::autoRepeat property which will cause the clicked() signal to be repeated when the QAbstractButton::autoRepeatInterval passes.

hakermania
8th April 2011, 16:32
Hey, wysota thx :)