This commit is contained in:
2025-09-28 17:05:51 +08:00
parent 8eb80ab66d
commit d97fa3e0fe
398 changed files with 18737 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 3.16)
project(8-PathAnimation VERSION 0.1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 6.4 REQUIRED COMPONENTS Quick)
qt_standard_project_setup()
qt_add_executable(app8-PathAnimation
main.cpp
)
qt_add_qml_module(app8-PathAnimation
URI 8-PathAnimation
VERSION 1.0
QML_FILES Main.qml
)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(app8-PathAnimation PROPERTIES
# MACOSX_BUNDLE_GUI_IDENTIFIER com.example.app8-PathAnimation
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
target_link_libraries(app8-PathAnimation
PRIVATE Qt6::Quick
)
include(GNUInstallDirs)
install(TARGETS app8-PathAnimation
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

View File

@@ -0,0 +1,89 @@
import QtQuick
Window {
id: rootId
width: 640
height: 480
visible: true
title: qsTr("PathAnimation")
Rectangle{
id: containerRectId
anchors.fill: parent
color: "beige"
Rectangle{
id: containedRectId
width: 100
height: 100
x: rootId.width/2 - 50
y: rootId.height - 50 -50
color: "dodgerblue"
radius: 80
PathAnimation{
id: pathAnimationId
target: containedRectId
duration: 1000
anchorPoint: Qt.point(50,50)
path: Path {
//Bottom : Starting Point
startX: rootId.width/2
startY: rootId.height - 50
// Towards Left
PathCubic {
x: 50
y: rootId.height/2
control1X: rootId.width/2 - rootId.width/8
control1Y: rootId.height
control2X: 0
control2Y: rootId.height/2 + rootId.height/8
}
//Towards Top: Q2
PathCubic {
x: rootId.width/2
y: 50
control1X: 0
control1Y: (rootId.height/2 - rootId.height/8)
control2X : (rootId.width/2 - rootId.width/8)
control2Y: 0
}
//Towards Right: Q3
PathCubic {
x: rootId.width - 50
y: rootId.height/2
control1X: rootId.width/2 + rootId.width/8
control1Y: 0
control2X: rootId.width
control2Y: rootId.height/2 - rootId.height/8
}
//Towards bottom: Q4
PathCubic {
x: rootId.width/2
y: rootId.height - 50
control1X: rootId.width
control1Y: rootId.height/2 + rootId.height/8
control2X: rootId.width/2 + rootId.width/8
control2Y: rootId.height
}
}
}
}
MouseArea{
anchors.fill: parent
onClicked: function(mouse){
pathAnimationId.start()
}
}
}
}

View File

@@ -0,0 +1,19 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
const QUrl url(u"qrc:/8-PathAnimation/Main.qml"_qs);
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreationFailed,
&app,
[]() { QCoreApplication::exit(-1); },
Qt::QueuedConnection);
engine.load(url);
return app.exec();
}