在 QGraphicsScene 中使用 QtimerEvent
定时器事件是 QGLWidget 类的成员,当调用 mousemove 函数时将被触发。我想我可以这样做:
void GLWidget::timerEvent(QTimerEvent *e)
{
if (e->timerId()==1 && refresh==true)
{
refresh = !refresh;
swapBuffers();
update();
}
}
它看起来像这样:
void OpenGLScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
int mousex = event->scenePos().x();
int mousey = event->scenePos().y();
if ((test->modus==2) && (test->move1 != -1))
{
p_list[test->move1].x=mousex-(1220);
p_list[test->move1].y=mousey-( 610);
test->refresh = !(test->refresh);
test->timerEvent(???);
update();
}
}
但不知怎的,我不知道在问号所在的地方放什么。我已经尝试了几件事。它不起作用。我想设置timerId()=1。 感谢您的帮助...
The timerEvent, which is a member of a QGLWidget class shall be triggered when the mousemove-function is called. I thought I could do it like this:
void GLWidget::timerEvent(QTimerEvent *e)
{
if (e->timerId()==1 && refresh==true)
{
refresh = !refresh;
swapBuffers();
update();
}
}
It looks like this:
void OpenGLScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
int mousex = event->scenePos().x();
int mousey = event->scenePos().y();
if ((test->modus==2) && (test->move1 != -1))
{
p_list[test->move1].x=mousex-(1220);
p_list[test->move1].y=mousey-( 610);
test->refresh = !(test->refresh);
test->timerEvent(???);
update();
}
}
But somehow I dont know what to put into where the questions marks are. I have tried several things. It is not working. I want to set timerId()=1.
Thanks for your help...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你为什么不调用你自己的事件,如:
并在你的 GLWidget 中:
why don't you call your own event like :
and in your GLWidget :