2 Nisan 2018 Pazartesi

QGestureRecognizer Sınıfı

Giriş
Şu satırı dahil ederiz.
#include <QGestureRecognizer>
create metodu
Şöyle yaparız.
QGesture *MyPanGestureRecognizer::create(QObject *target)
{
  return  new QPanGesture();
}
recognize metodu
Şöyle yaparız.
QGestureRecognizer::Result MyPanGestureRecognizer::recognize(QGesture *state,
  QObject *, QEvent *event)
{
  QMouseEvent * mouse = dynamic_cast<QMouseEvent*>(event);

  if(mouse->type() == QMouseEvent::MouseButtonPress)
  {
    QPanGesture * gesture = dynamic_cast<QPanGesture*>(state);
    if(gesture != 0)
    {
      ...
      return TriggerGesture;
    }
  }
  if(panning && (mouse->type() == QMouseEvent::MouseMove))
  {
    QPanGesture * gesture = dynamic_cast<QPanGesture*>(state);
    if(gesture != 0)
    {
      ...
      return TriggerGesture;
    }
  }
  if(mouse->type() == QMouseEvent::MouseButtonRelease)
  {
    QPanGesture * gesture = dynamic_cast<QPanGesture*>(state);
    if(gesture != 0)
    {
      ...
      return FinishGesture;
    }
  }
  if(mouse->type() == QMouseEvent::MouseButtonDblClick)
  {
    ...
    return CancelGesture;
  }
  return Ignore;
}
registerRecognizer metodu
Şöyle yaparız.
QGestureRecognizer::registerRecognizer(new MyPanGestureRecognizer());

Hiç yorum yok:

Yorum Gönder