Skip to content
QtWS25 Call for Papers
  • Cross Swipe Screens

    Solved QML and Qt Quick
    4
    0 Votes
    4 Posts
    296 Views
    M

    @Matheus-da-Silva-Ribeiro Please mark your answer as "Correct Answer" to change title to "Solved".

  • 0 Votes
    13 Posts
    2k Views
    L

    The following partially works and I post in the hopes that someone might get an idea that will fix my issue :)

    bool ZoomCode::event(QEvent *event) { if (event->type() == QEvent::NativeGesture) { return gestureEvent(static_cast<QNativeGestureEvent*>(event)); } return QWidget::event(event); } bool ZoomCode::gestureEvent(QNativeGestureEvent *e) { float value = e->value(); textEdit->setFontPointSize(NULL); // zoom does not work without this textEdit->selectAll(); // some part of the text has to be selected before the zoom in the text starts to work. It does NOT matter if it is the WHOLE text or just a character in the text, just as long as something gets highlighted. Afterwards, nothing has to be highlighted again for the zoom to work. The zoom works on the whole text, no matter what part has been highlighted. if(value >0) { zoomIn(value + 5); // + 5 to add some zoom strength } else if(value < 0) zoomOut(value - 5); // -5 to add some zoom strength } }
  • 0 Votes
    1 Posts
    861 Views
    No one has replied
  • 0 Votes
    1 Posts
    446 Views
    No one has replied
  • 1 Votes
    8 Posts
    11k Views
    SeeLookS

    @Qt-embedded-developer I'm sorry but I don't remember well...
    It was long time ago and I ported my app to QML since then.
    In QML it is much much easier to achieve such things.
    I tried to dig the old QtWidgets code but I've not found where it was yet.

  • 0 Votes
    14 Posts
    12k Views
    C

    @QTUserForAndroid This should help to 'mark as solved' and other forum inquiries:

    https://forum.qt.io/topic/62700/hitchhiker-s-visual-guide-to-the-qt-forum

  • 0 Votes
    1 Posts
    698 Views
    No one has replied
  • 0 Votes
    8 Posts
    3k Views
    M

    Yes that is correct. Every of the 8 custom gestures defines its own set of data in addition to the QGestureState, which is set by the according gesture recognizer.

    I now implemented an abstract superclass for all these gestures with a method getGestureData(). This method basically wraps all the data in a QMap<QString,QVariant> to make a general gesture treatment possible. The custom event GestureEvent now takes gesture type, the Qt::GestureState and the mentioned gesture data map.
    It was a little bit circumstantial, but now it works.

    Thanks again,
    Malte

  • 0 Votes
    10 Posts
    4k Views
    X

    I found out the solution using native Windows Gestures WM_Gesture.
    By default QT registers QMainWindow-Window as a Touch Window, so the QMainWindow-App only get WM_Touch events.
    As said above one can only get either WM_Touch event or WM_Gesture event. So you have to unregister the window from getting Touch event. I do that in the constructor like this:

    HWND myHwnd = reinterpret_cast<HWND>(this->winId()); PULONG flag = 0; bool istouch = IsTouchWindow(myHwnd,flag); if(istouch) UnregisterTouchWindow(myHwnd);

    now i get WM_Gesture events in nativeEvent:

    bool OpenGLWindow::nativeEvent(const QByteArray & eventType, void* message, long* result) { MSG* msg = reinterpret_cast<MSG*>(message); switch(msg->message){ case WM_GESTURE: case WM_GESTURENOTIFY: emit sendNativeEvent(eventType, message, result); break; } return false; }

    Thanks for your help.