diff --git a/Exam/Exam1/background.png b/Exam/Exam1/background.png new file mode 100644 index 0000000000000000000000000000000000000000..c9b7d89ae393ac7926380d6260f00db7d1d4e63c Binary files /dev/null and b/Exam/Exam1/background.png differ diff --git a/Exam/Exam1/blur.png b/Exam/Exam1/blur.png new file mode 100644 index 0000000000000000000000000000000000000000..828ddc426d6a08f37390b615ba0f08479ae4f7ef Binary files /dev/null and b/Exam/Exam1/blur.png differ diff --git a/Exam/Exam1/pinwheel.png b/Exam/Exam1/pinwheel.png new file mode 100644 index 0000000000000000000000000000000000000000..e70b977a341f3b890093302f27f879a49e57f6ec Binary files /dev/null and b/Exam/Exam1/pinwheel.png differ diff --git a/Exam/Exam1/pole.png b/Exam/Exam1/pole.png new file mode 100644 index 0000000000000000000000000000000000000000..ccb9b33a6660a8bc09103a2be94f8f99d1bf0813 Binary files /dev/null and b/Exam/Exam1/pole.png differ diff --git a/Exam/Exam2.qml b/Exam/Exam2.qml new file mode 100644 index 0000000000000000000000000000000000000000..38cdce81e7903a5949bce4f9bcd748bcd2a5bb97 --- /dev/null +++ b/Exam/Exam2.qml @@ -0,0 +1,38 @@ +import QtQuick + +Rectangle { + id: root + + width: 120; height: 240 + color: "#4A4A4A" + + onWidthChanged: { + root.updateX() + } + + Component.onCompleted: { + root.updateX() + } + + function updateX () { + rectItem.x = (width - rectItem.width)/2 + } + + Rectangle { + id: rectItem + + y: 40 + width: 100 + height: 100 + color: "white" + } + + Text { + y: rectItem.y + rectItem.height + 20 + width: root.width + color: 'white' + horizontalAlignment: Text.AlignHCenter + text: "Property binding" + } +} + diff --git a/Exam/Exam3.qml b/Exam/Exam3.qml new file mode 100644 index 0000000000000000000000000000000000000000..92a1b680ca5bbdb0fa16c074fcacfa51e4955a70 --- /dev/null +++ b/Exam/Exam3.qml @@ -0,0 +1,51 @@ +import QtQuick + +Item { + id: main + width: 1280 + height: 720 + + Rectangle { + width: main.width / 3 + height: main.height + color: "lightcoral" + + Text { + x: 50 + font.bold: true + font.pointSize: 40 + anchors.verticalCenter: parent.verticalCenter + text: "1" + } + } + + Rectangle { + x: main.width / 3 + width: main.width / 3 + height: main.height + color: "orange" + + Text { + x: 50 + font.bold: true + font.pointSize: 40 + anchors.verticalCenter: parent.verticalCenter + text: "2" + } + } + + Rectangle { + x: main.width / 3 * 2 + width: main.width / 3 + height: main.height + color: "lightgreen" + + Text { + x: 50 + font.bold: true + font.pointSize: 40 + anchors.verticalCenter: parent.verticalCenter + text: "3" + } + } +} diff --git a/Exam_Day2/ImageSequence.qml b/Exam_Day2/ImageSequence.qml new file mode 100644 index 0000000000000000000000000000000000000000..43c5680a1476c17ad88d795f20e901d1364d2d2b --- /dev/null +++ b/Exam_Day2/ImageSequence.qml @@ -0,0 +1,22 @@ +import QtQuick + +Item { + width: 600 + height: 600 + + Image { + id: image + property int index: 1 + property string indexString: "01" + + Timer { + running: true + repeat: true + interval: 200 + onTriggered: { + //hint - toString().padStart(2,0) + + } + } + } +} diff --git a/Exam_Day2/image/01.jpeg b/Exam_Day2/image/01.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..f2ca1df2cd98d30484ead455d503a60b49fb348f Binary files /dev/null and b/Exam_Day2/image/01.jpeg differ diff --git a/Exam_Day2/image/02.jpeg b/Exam_Day2/image/02.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..8c799b253ecdd4c75c4fd6de81ed01231ae7e95b Binary files /dev/null and b/Exam_Day2/image/02.jpeg differ diff --git a/Exam_Day2/image/03.jpeg b/Exam_Day2/image/03.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..cef65beef526957da3889f3e6eb51fd841d4e300 Binary files /dev/null and b/Exam_Day2/image/03.jpeg differ diff --git a/Exam_Day2/image/04.jpeg b/Exam_Day2/image/04.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..2432015966ceff493beff083feafbd885691de81 Binary files /dev/null and b/Exam_Day2/image/04.jpeg differ diff --git a/Exam_Day2/image/05.jpeg b/Exam_Day2/image/05.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..32e3958b48eebb0e9e372f873dbfb1f2e532d98a Binary files /dev/null and b/Exam_Day2/image/05.jpeg differ diff --git a/Exam_Day2/image/06.jpeg b/Exam_Day2/image/06.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..a631712806bf9595c203d85ad48211c9085d1953 Binary files /dev/null and b/Exam_Day2/image/06.jpeg differ diff --git a/Exam_Day2/image/07.jpeg b/Exam_Day2/image/07.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..057f89017905d1e01514bcd9c364796bf78f9f3c Binary files /dev/null and b/Exam_Day2/image/07.jpeg differ diff --git a/Exam_Day2/image/08.jpeg b/Exam_Day2/image/08.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..75dc6f58adf81da5339791c50a37e3b751e55d48 Binary files /dev/null and b/Exam_Day2/image/08.jpeg differ diff --git a/Exam_Day2/image/09.jpeg b/Exam_Day2/image/09.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..b2d8659d5d0c58a69fdde0af4652735d3b078258 Binary files /dev/null and b/Exam_Day2/image/09.jpeg differ diff --git a/Exam_Day2/image/10.jpeg b/Exam_Day2/image/10.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..70b24135ef90f548f0d5d08afcf985215234e0b9 Binary files /dev/null and b/Exam_Day2/image/10.jpeg differ diff --git a/Exam_Day2/image/11.jpeg b/Exam_Day2/image/11.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..1832654b9cad594c9b128b7862bb15a181e1e4dd Binary files /dev/null and b/Exam_Day2/image/11.jpeg differ diff --git a/Exam_Day2/image/12.jpeg b/Exam_Day2/image/12.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..b206ebf36f21618688132daedb7cb00958a0fac2 Binary files /dev/null and b/Exam_Day2/image/12.jpeg differ diff --git a/Exam_Day2/image/13.jpeg b/Exam_Day2/image/13.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..8c799b253ecdd4c75c4fd6de81ed01231ae7e95b Binary files /dev/null and b/Exam_Day2/image/13.jpeg differ diff --git a/Exam_Day2/image/14.jpeg b/Exam_Day2/image/14.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..48efb1a1b6534105913c458931ca67b10ef63e75 Binary files /dev/null and b/Exam_Day2/image/14.jpeg differ diff --git a/Exam_Day2/image/15.jpeg b/Exam_Day2/image/15.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..db143b88cadc061762c94716b2e21351172429fe Binary files /dev/null and b/Exam_Day2/image/15.jpeg differ diff --git a/Exam_Day2/image/16.jpeg b/Exam_Day2/image/16.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..4bac7c777f7633da10e6797838dea0e2be25d6ec Binary files /dev/null and b/Exam_Day2/image/16.jpeg differ diff --git a/Exam_Day2/image/17.jpeg b/Exam_Day2/image/17.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..12dea4b8e228b8d3c356273994becf4749e7cc1a Binary files /dev/null and b/Exam_Day2/image/17.jpeg differ diff --git a/Exam_Day3/Qt6SM_1/CMakeLists.txt b/Exam_Day3/Qt6SM_1/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..d813aa1a6f70fd13ce6c373c5b014969014b6563 --- /dev/null +++ b/Exam_Day3/Qt6SM_1/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.16) + +project(Qt6SM_1 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(appQt6SM_1 + main.cpp sharedmemorysetter.h sharedmemorysetter.cpp +) + +qt_add_qml_module(appQt6SM_1 + URI Qt6SM_1 + 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(appQt6SM_1 PROPERTIES +# MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appQt6SM_1 + 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(appQt6SM_1 + PRIVATE Qt6::Quick +) + +include(GNUInstallDirs) +install(TARGETS appQt6SM_1 + BUNDLE DESTINATION . + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/Exam_Day3/Qt6SM_1/Main.qml b/Exam_Day3/Qt6SM_1/Main.qml new file mode 100644 index 0000000000000000000000000000000000000000..7a927bcdb6a0d1e2ec651eb5384d904df8c6acc8 --- /dev/null +++ b/Exam_Day3/Qt6SM_1/Main.qml @@ -0,0 +1,39 @@ +import QtQuick +import QtQuick.Controls.Material +import QtQuick.Dialogs +import QtQuick.Window + + +Window { + width: 700 + height: 700 + visible: true + title: qsTr("Hello World") + + Image { + id: image + anchors.centerIn: parent + } + + Button { + text: "Open" + anchors { + right: parent.right + bottom: parent.bottom + margins: 20 + } + onClicked: { + dialog.open() + } + } + + FileDialog { + id: dialog + nameFilters: ["Image files (*.png, *.jpeg)"] + + onAccepted: { + console.log(selectedFile) + image.source = selectedFile + } + } +} diff --git a/Exam_Day3/Qt6SM_1/main.cpp b/Exam_Day3/Qt6SM_1/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9ee064795526119fc646efbedd5e4271e75f4f22 --- /dev/null +++ b/Exam_Day3/Qt6SM_1/main.cpp @@ -0,0 +1,17 @@ +#include <QGuiApplication> +#include <QQmlApplicationEngine> + + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + const QUrl url(u"qrc:/Qt6SM_1/Main.qml"_qs); + QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, + &app, []() { QCoreApplication::exit(-1); }, + Qt::QueuedConnection); + engine.load(url); + + return app.exec(); +} diff --git a/Exam_Day3/Qt6SM_1/sharedmemorysetter.cpp b/Exam_Day3/Qt6SM_1/sharedmemorysetter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a42f7d920b9ec316a59ffb3347407cd5ff419a06 --- /dev/null +++ b/Exam_Day3/Qt6SM_1/sharedmemorysetter.cpp @@ -0,0 +1,23 @@ +#include "sharedmemorysetter.h" + +#include <QDebug> +#include <QFile> +#include <QUrl> + +SharedMemorySetter::SharedMemorySetter(QObject *parent) + : QObject{parent}, sm("ImageData") +{ + +} + +void SharedMemorySetter::writeImageToSM(QUrl url) +{ + QFile image(url.toLocalFile()); + qDebug() << "file open" << image.open(QIODevice::ReadOnly); + QByteArray raw = image.readAll(); + qDebug() << "file size" << raw.size(); + qDebug() << "Shared Memory create" << sm.create(raw.size()); + qDebug() << "Shared Memory lock" << sm.lock(); + memcpy(sm.data(), raw.data(), raw.size()); + qDebug() << "Shared Memory unlock" << sm.unlock(); +} diff --git a/Exam_Day3/Qt6SM_1/sharedmemorysetter.h b/Exam_Day3/Qt6SM_1/sharedmemorysetter.h new file mode 100644 index 0000000000000000000000000000000000000000..1e7b39f21219a0e62df50c7356311f02dce887b2 --- /dev/null +++ b/Exam_Day3/Qt6SM_1/sharedmemorysetter.h @@ -0,0 +1,23 @@ +#ifndef SHAREDMEMORYSETTER_H +#define SHAREDMEMORYSETTER_H + +#include <QObject> +#include <QQmlEngine> +#include <QSharedMemory> + +class SharedMemorySetter : public QObject +{ + Q_OBJECT + +public: + explicit SharedMemorySetter(QObject *parent = nullptr); + +public: + Q_INVOKABLE void writeImageToSM(QUrl url); + +private: + QSharedMemory sm; + +}; + +#endif // SHAREDMEMORYSETTER_H diff --git a/Exam_Day3/Qt6SM_2/CMakeLists.txt b/Exam_Day3/Qt6SM_2/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..899d93084c4ccb812e57669392cf408ad711297e --- /dev/null +++ b/Exam_Day3/Qt6SM_2/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.16) + +project(Qt6SM_2 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(appQt6SM_2 + main.cpp +) + +qt_add_qml_module(appQt6SM_2 + URI Qt6SM_2 + 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(appQt6SM_2 PROPERTIES +# MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appQt6SM_2 + 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(appQt6SM_2 + PRIVATE Qt6::Quick +) + +include(GNUInstallDirs) +install(TARGETS appQt6SM_2 + BUNDLE DESTINATION . + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/Exam_Day3/Qt6SM_2/Main.qml b/Exam_Day3/Qt6SM_2/Main.qml new file mode 100644 index 0000000000000000000000000000000000000000..a8d8f78f99458e30d51082f2229c5dc72f69e019 --- /dev/null +++ b/Exam_Day3/Qt6SM_2/Main.qml @@ -0,0 +1,27 @@ +import QtQuick +import QtQuick.Controls.Material +import QtQuick.Window + +Window { + width: 700 + height: 700 + visible: true + title: qsTr("Hello World") + + Image { + id: image + anchors.centerIn: parent + } + + Button { + text: "Load" + anchors { + right: parent.right + bottom: parent.bottom + margins: 20 + } + onClicked: { + console.log(image.source) + } + } +} diff --git a/Exam_Day3/Qt6SM_2/main.cpp b/Exam_Day3/Qt6SM_2/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ea0d284414497b6903d36b0eddc45b4e8eb85ffa --- /dev/null +++ b/Exam_Day3/Qt6SM_2/main.cpp @@ -0,0 +1,43 @@ +#include <QGuiApplication> +#include <QQmlApplicationEngine> +#include <QQuickImageProvider> +#include <QSharedMemory> + +class SMImageProvider : public QQuickImageProvider +{ +public: + SMImageProvider() + : QQuickImageProvider(QQuickImageProvider::Pixmap) + { + } + + QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override + { + qDebug() << Q_FUNC_INFO; + QPixmap image; + QSharedMemory sm("ImageData"); + qDebug() << sm.attach(); + qDebug() << sm.lock(); + qDebug() << sm.size(); + QByteArray data((const char*)sm.data(), sm.size()); + image.loadFromData(data, "JPEG"); + sm.unlock(); + sm.detach(); + return image; + } +}; + + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + const QUrl url(u"qrc:/Qt6SM_2/Main.qml"_qs); + QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, + &app, []() { QCoreApplication::exit(-1); }, + Qt::QueuedConnection); + engine.load(url); + + return app.exec(); +} diff --git a/QML.pdf b/QML.pdf new file mode 100644 index 0000000000000000000000000000000000000000..915bb185561e76ab37941b5bc55a00db5b3b00be Binary files /dev/null and b/QML.pdf differ diff --git a/README.md b/README.md index 9d10c9193bff948e6091d3edf18549ac52780ccf..9e35d999452d51b5fcf2bbf3eeac467e5b4b9e0c 100644 --- a/README.md +++ b/README.md @@ -1,93 +1 @@ -# qml_training - - - -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://git.qt.io/belee/qml_training.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://git.qt.io/belee/qml_training/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README - -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +# qml_training \ No newline at end of file