Andre Poenitz wrote:
> On Wed, May 30, 2007 at 03:59:15PM -0400, Richard Heck wrote:
>   
>> +    if (obj == availableLV) {
>> +            if (event->type() != QEvent::KeyPress)
>> +                    return QObject::eventFilter(obj, event);
>> +            QKeyEvent * keyEvent = static_cast<QKeyEvent *>(event);
>> +            int const keyPressed = keyEvent->key();
>> +            Qt::KeyboardModifiers const keyModifiers = 
>> keyEvent->modifiers();
>> +            //Enter key without modifier will add current item
>> +            //...with control modifier will add it and close the dialog
>> +            if ((keyPressed ==      Qt::Key_Enter || keyPressed == 
>> Qt::Key_Return) &&
>>     
>
> ------------------------^
> Space. Also please spaces after the ///
>   
Thanks. It looked like a space on my editor but was in fact a tab.
>> +                            (!keyModifiers || 
>> +                             (keyModifiers == Qt::ControlModifier) ||
>> +                             (keyModifiers == Qt::KeypadModifier)  ||
>> +                             (keyModifiers == (Qt::ControlModifier | 
>> Qt::KeypadModifier))
>>     
>
> Would that be equivalent to
>
>        !(keyModifiers & ~(Qt::ControlModifier | Qt::KeypadModifier))
>
> Hm... even if so, it does it look simpler? I am uncertain.
>   
No, not the same: If you have Ctrl, Shift, and Keypad, it would pass. I
played with this for a while (I teach logic) and didn't get anywhere
real sensible. I decided to stick with something intelligible.
Presumably the compiler will figure it out. But I'll add a comment.
> I never used KeypadModifier myself...
>   
If you hit Enter on the Keypad, then Qt gives you Qt::Key_Enter and
Qt::KeypadModifier. So just checking for Qt::ControlModifier doesn't
work (as I found out). I'm trying NOT to capture Ctrl-Shift-Enter. Maybe
that would do something else....

Richard

-- 
==================================================================
Richard G Heck, Jr
Professor of Philosophy
Brown University
http://frege.brown.edu/heck/
==================================================================
Get my public key from http://sks.keyserver.penguin.de
Hash: 0x1DE91F1E66FFBDEC
Learn how to sign your email using Thunderbird and GnuPG at:
http://dudu.dyn.2-h.org/nist/gpg-enigmail-howto

Reply via email to