[Qt-interest] which key(s) pressed for current widget?
James Yan
jyan972 at gmail.com
Wed Dec 17 13:03:59 CET 2008
hey all,
i create a widget where i can draw and move points on it, and allow user to
move points with two methods, so i want to separate two methods with user's
key press: if CTRL is pressed or not while mouse moved.
so i think it can be impletmented with keyPressEvent / keyReleaseEvent in
this way:
mywidget::keyPressEvent( QKeyEvent * event )
{
key = event->key(); //save which key pressed
}
mywidget::keyReleaseEvent ( QKeyEvent * event )
{
key = -1; // no key pressed from now
}
mywidget::movePoint()
{
if(key == CTRL)
{
//move points with method #1
}
else
{
//move points with method #2
}
}
but the result of above idea and code do not works, i already setFocusPolicy
so widget can revice key.
any wrong with it? my problem can be solved with keyPressEvent /
keyReleaseEvent?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20081217/2c03a3ae/attachment.html
More information about the Qt-interest-old
mailing list