交互设计在未来很有前途,不要再说是做界面的了。
分类:
2012-02-16 16:15:32
Panel::keyPressEvent(QKeyEvent *event)
{
qDebug("event >>>>>>>>>>>>>>>modifier %x\n",event->modifiers());
QTransform transform ;
static int degree = 0;
static int zdegree = 0;
if (event->modifiers()&Qt::ControlModifier)
{
if (event->key() == Qt::Key_Up)
degree+= 10;
else if (event->key() == Qt::Key_Down)
{
degree -= 10;
if (degree < 0)
degree += 360;
}
else if (event->key() == Qt::Key_Right)
{
zdegree += 10;
}
else if (event->key() == Qt::Key_Left)
{
zdegree -= 10;
if (zdegree < 0)
zdegree += 360;
}
}
degree%= 360;
zdegree%= 360;
transform.translate(scene->sceneRect().x()+scene->sceneRect().width()/2,scene->sceneRect().y()+scene->sceneRect().height()/2);
transform.rotate(degree, Qt::XAxis);
transform.rotate(zdegree, Qt::ZAxis);
transform.translate(-1*(scene->sceneRect().x()+scene->sceneRect().width()/2),-1*(scene->sceneRect().y()+scene->sceneRect().height()/2));
baseItem->setTransform(transform);
}