PDA

View Full Version : [Multi click] What about x-ple click where x > 2 ?



lauranger
24th August 2006, 11:48
Hi,
Is there a (nice) way to get multiple click events in Qt ?
Googling on the subject lead me to short threads in mailing-lists
with one asking (and even proposing code if I got it well)
and nobody answering.
Is there any negative recommendation by trolltech or anyone else
on the subject, explaning this absence of feature ?
Regards.

high_flyer
24th August 2006, 12:38
Multiple clicks (i.e more then one and not double click) are nothing more then normal clicks where you just need to compare the time difference between the clicks agaist a defined threshold.
Where is the problem?

lauranger
24th August 2006, 14:03
Thanks for replying, high_flyer. :)
"Where is the problem ?"
In the ease of using it. What would you say if double was not
pre-baked by Qt in the form of a virtual method mouseDoubleClickEvent ?
A library, a framework is supposed to help get things done simpler, no ?
I wish MouseEvent had a "multiClickCount" or something of that meaning.
I guess it would not have cost that much as the time comparison is already
executed for double click... I thought... and then read the source. OK this seems
to be heavily system dependent. But QTextEdit has some thing of this kind in its source...
Regards

high_flyer
24th August 2006, 14:37
In the ease of using it. What would you say if double was not
pre-baked by Qt in the form of a virtual method mouseDoubleClickEvent ?
I don't agree with your statment.
A single left and right clicks as well as left double click became a standard use of mouse button long ago.
Since practically every GUI application uses some or all of those it makes sense to have them in a GUI library.
But multi clicks are not a standard practice, therefore, I would not excpect it to be built in Qt.

A library, a framework is supposed to help get things done simpler, no ?
Yes.
And Qt is great at doing that.
Qt covers lots of frequently used tasks in GUI and non GUI applications alike, but it can't cover ALL wishes of everyone, you have to agree about that - so where should one draw the line on what to implement and what not?
Surely you have to agree that the degree of how much a feature is used is a good mesure to decide that.

I wish MouseEvent had a "multiClickCount" or something of that meaning.
Well, I wish Qt had many other features...
But that would take all the fun out of coding... ;)

I guess it would not have cost that much as the time comparison is already
executed for double click... I thought... and then read the source. OK this seems
to be heavily system dependent.
Qt offers you all the tools to do that easely, and it is NOT system dependent, since QTimer/QTime is not system dependent nor is QMouseEvent.

But QTextEdit has some thing of this kind in its source...
Thats one way to go about it, (reading in to Qt source) but the problem is really simple... just few lines of code...



MyWidget::mouseReleaseEvent ( QMouseEvent * event )
{
clickTimer.start(m_timeout);
}

MyWidget::mousePressEvent( QMouseEvent * event )
{
clickTimer.stop();
m_clickCounter++;
}

//the slot to be executed when clickTimer timesout
void MyWidget::multiClickSlot()
{
switch(m_clickCounter)
{
case 3: //do something
break;
case 4: //do somthing else
}
}


Or something similar... :D

lauranger
24th August 2006, 15:07
"something similar" is OK for me ;)
My post was not a rant. I like Qt a lot :)

wysota
24th August 2006, 16:01
"Multiclicking" (with multi > 2) is not a good design. It's much better to use a single or double click with a keyboard modifier (shift, ctrl, ...) instead.

lauranger
24th August 2006, 16:12
"Multiclicking" (with multi > 2) is not a good design. It's much better to use a single or double click with a keyboard modifier (shift, ctrl, ...) instead.
That's a good point : I rarely use quadruple-click for rectangular selection in vim but use Ctrl-V in stead. /o\
But on the other side triple click for whole line selection has become a standard. (And QTextEdit features it, as already stated).
Modifiers are easier to master than click multiplicity and offer more usable combinations.
So this is a better alternative. :)
Thanks Wysota.

wysota
25th August 2006, 01:24
But on the other side triple click for whole line selection has become a standard. (And QTextEdit features it, as already stated).
Nobody said things considered a standard are always good solutions to problems.