PDA

View Full Version : Strange problem with events on Unix



sukanyarn
6th November 2006, 12:02
Hi,

I am implementing plain text editor using QTextEdit.
I have reimplemented MousePressEvent to make sure that ALT and CONTROL buttons are pressed simultaneously during mouse press event.

This is working fine on windows environment. But the same is not working fine on UNIX environment.

On UNIX the following condition is not being true even though all the criterias are met.

"(me->state() & Qt::AltButton) && (me->state() & Qt::ControlButton)" is not being identified on unix.

Following is the code snippet.

I am calling processMousePressEvent function once mousePressEvent Occurs.
void Editor::processMousePressEvent( QMouseEvent *me )
{

// Control comes here
//With the key press of Alt and Control button only the selection of text can happen
if( (me->state() & Qt::AltButton) && (me->state() & Qt::ControlButton) )
{
m_bCopyColumn = true;
}
else
m_bCopyColumn = false;
}

The above code is working very well on windows.

I wonder how QT is behaving differently on UNIX and Windows.

Please give some suggestions.

Thanks in advance.

jacek
7th November 2006, 00:55
Maybe you don't press alt but meta key?

Mad Max
7th November 2006, 02:45
from Qt's manual (a part of the description of QMouseEvent::state () method ) :

This value is mainly interesting for QEvent::MouseMove; for the other cases, button() is more useful.