Skip to content
  • 0 Votes
    4 Posts
    218 Views
    Christian EhrlicherC

    Then please fill a bug report. Maybe there is already one.

  • 0 Votes
    3 Posts
    245 Views
    D

    @SGaist Its about precision moves, if user wants to move by tiny bit, scaling mouse movement by x value would allow that to happen. Else he would have to type 0.0001 0.0002 0.0003 etc etc.

    I think I could handle it using itemChange() and record initial mouse click press/release and calculate delta using that..

    Yep that seem to do the trick... I can now move my items by tiny amount and doing "Long precise drags"

    deltaX = (newPos.x() - self.mMousePressPosition.x()) / 2 newPos.setX(newPos.x() - deltaX) deltaY = (newPos.y() - self.mMousePressPosition.y()) / 2 newPos.setY(newPos.y() - deltaY)

    Small edit, function above works for "simple" items, but as soon as I get to child items with parent it appear to break... sigh. Needs some more math there

  • 0 Votes
    5 Posts
    5k Views
    tobiSFT

    Thanks, that was exactly what I was looking for. Works like a charm now!

  • 0 Votes
    2 Posts
    5k Views
    Diego DonateD

    I have changed the structure, I have used a QQuickWidget with a QML inside, and now I have what I wanted. Here is my code in case anyone needs something similar

    main.cpp

    ... MovableWidget *view = new MovableWidget; view->setSource(QUrl("qrc:/Test.qml")); view->setWindowFlags(Qt::FramelessWindowHint); view->show(); ...

    Test.qml

    import QtQuick 2.0 Rectangle { id: myWindow width: 500; height: 500 color: "yellow" Rectangle { anchors.centerIn: parent width: 200; height: 200 color: "red" } }

    MovableWidget.cpp

    #include "movableWidget.h" #include <QMouseEvent> // ************************************************** ************************** MovableWidget::MovableWidget(QWidget *parent) : QQuickWidget(parent), m_previousPos(0,0) { installEventFilter(this); } // ************************************************** ************************** bool MovableWidget::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::MouseButtonPress) { m_previousPos = QCursor:os(); } else if (event->type() == QEvent::MouseMove) { QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); if(mouseEvent->buttons() == Qt::LeftButton) { QPoint offset = m_previousPos - QCursor:os(); m_previousPos = QCursor:os(); move(pos() - offset); } } return false; }
  • Move line in a scene

    Solved General and Desktop
    3
    0 Votes
    3 Posts
    2k Views
    AlvaroSA

    @mrjj hi my friend. You helped me a lot. That works fine!!!!!!!
    Superb!!!!!!!
    Thanks again

  • 0 Votes
    1 Posts
    629 Views
    No one has replied
  • 0 Votes
    2 Posts
    913 Views
    SGaistS

    Hi,

    Please don't post the same question in multiple sub-forum, on is enough.

    Duplicate

    Closing this one.

  • 0 Votes
    2 Posts
    1k Views
    RatzzR

    Hi,
    Do you see CONFIG+=qml_debug in your pro file ? which means you have enabled QML debugging (actually it's on by default) . if you remove it then it is disabled.
    And just try in release mode.

  • Smooth character movement

    Unsolved Game Development
    27
    0 Votes
    27 Posts
    9k Views
    8Observer88

    I added the next comment to the bug report: https://bugreports.qt.io/browse/QTBUG-123862

    Try to run my example on macOS and Linux. Maybe it is a Windows issue. But requestAnimationFrame works perfectly smoothly on Windows: https://plnkr.co/edit/DebSXYMQ6TlgC7KT?preview It has a fixed 60 FPS, which means that the load on the processor is minimal.

    The worst result was with swapInterval=1, which I had at the beginning (I had not tried other values before). swapInterval with 0 and 10 is better, but not as good as requestAnimationFrame in JavaScript: https://plnkr.co/edit/B5t34XdK3MVi1WNb?preview (it is just a translation animation). I attached a source code "simple-translation-animation" (without rotation and scale animations). I attached EXE files for swapInterval = 0, swapInterval = 1, and swapInterval = 10:

    swapInterval = 0 - simple-translation-animation-opengles2-qt6-cpp-win10x64-exe-swap-interval-0.zip swapInterval = 1 - simple-translation-animation-opengles2-qt6-cpp-win10x64-exe-swap-interval-1.zip swapInterval = 10 - simple-translation-animation-opengles2-qt6-cpp-win10x64-exe-swap-interval-10.zip

    4623e1c6-0872-494d-881f-3b9677f8c17c-image.png

  • 0 Votes
    2 Posts
    2k Views
    M

    @MrKozmon

    I'm having the exact same problem on Android. When I drag a QQuickWidget that is hosting a QML-based WebView on Android, the widget moves but the WebView is left in the original position. Wondering if there has been any progress or a workaround for this issue.

    I am using Qt 5.10.0, developing for an x86 Android platform.