add book
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(6-SmoothedAnimation 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(app6-SmoothedAnimation
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app6-SmoothedAnimation
|
||||
URI 6-SmoothedAnimation
|
||||
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(app6-SmoothedAnimation PROPERTIES
|
||||
# MACOSX_BUNDLE_GUI_IDENTIFIER com.example.app6-SmoothedAnimation
|
||||
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(app6-SmoothedAnimation
|
||||
PRIVATE Qt6::Quick
|
||||
)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(TARGETS app6-SmoothedAnimation
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
@@ -0,0 +1,71 @@
|
||||
import QtQuick
|
||||
|
||||
Window {
|
||||
width: 640
|
||||
height: 480
|
||||
visible: true
|
||||
title: qsTr("SmoothedAnimation")
|
||||
|
||||
/*
|
||||
Rectangle{
|
||||
id: containerRectId
|
||||
anchors.fill: parent
|
||||
color: "beige"
|
||||
|
||||
Rectangle{
|
||||
id: containedRectId
|
||||
width: 100
|
||||
height: 100
|
||||
x: 50
|
||||
y: 50
|
||||
color: "dodgerblue"
|
||||
|
||||
|
||||
SmoothedAnimation{
|
||||
id: smoothedAnimationId
|
||||
target: containedRectId
|
||||
property: "x"
|
||||
duration: 2000
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
onClicked: function(mouse){
|
||||
smoothedAnimationId.from = containedRectId.x
|
||||
smoothedAnimationId.to = mouse.x
|
||||
smoothedAnimationId.start()
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Rectangle{
|
||||
anchors.fill: parent
|
||||
color: "lightgray"
|
||||
|
||||
Rectangle {
|
||||
//The rectangle doing the tracking
|
||||
width: 60; height: 60
|
||||
x: rect1.x - 5; y: rect1.y - 5
|
||||
color: "green"
|
||||
|
||||
Behavior on x { SmoothedAnimation { velocity: 200 } }
|
||||
Behavior on y { SmoothedAnimation { velocity: 200 } }
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
//The rectangle being tracked.
|
||||
id: rect1
|
||||
width: 50; height: 50
|
||||
color: "red"
|
||||
}
|
||||
|
||||
focus: true
|
||||
Keys.onRightPressed: rect1.x = rect1.x + 100
|
||||
Keys.onLeftPressed: rect1.x = rect1.x - 100
|
||||
Keys.onUpPressed: rect1.y = rect1.y - 100
|
||||
Keys.onDownPressed: rect1.y = rect1.y + 100
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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:/6-SmoothedAnimation/Main.qml"_qs);
|
||||
QObject::connect(
|
||||
&engine,
|
||||
&QQmlApplicationEngine::objectCreationFailed,
|
||||
&app,
|
||||
[]() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.load(url);
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user