diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..aa3808c5a9e01bdb4728d53628e036914f616c56 --- /dev/null +++ b/.gitignore @@ -0,0 +1,82 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* +*.qbs.user* +CMakeLists.txt.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + +# Directories with generated files +.moc/ +.obj/ +.pch/ +.rcc/ +.uic/ +/build*/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..0540a490bf903b8d10ff2839d8c7223ae9d66adf --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,43 @@ +cmake_minimum_required(VERSION 3.16) + +project(suduko VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(Qt6 REQUIRED COMPONENTS Quick) + +qt_standard_project_setup(REQUIRES 6.5) + +qt_add_executable(appsuduko + main.cpp +) + +qt_add_qml_module(appsuduko + URI suduko + VERSION 1.0 + QML_FILES + Main.qml + RESOURCES Sudoku.qrc +) + +# 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(appsuduko PROPERTIES +# MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appsuduko + 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(appsuduko + PRIVATE Qt6::Quick +) + +include(GNUInstallDirs) +install(TARGETS appsuduko + BUNDLE DESTINATION . + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/Main.qml b/Main.qml new file mode 100644 index 0000000000000000000000000000000000000000..1e48b4bf23ddc275790fc555cfa05bcbafe4b5cf --- /dev/null +++ b/Main.qml @@ -0,0 +1,145 @@ +import QtQuick + +Window { + width: 500 + height: 520 + visible: true + property alias rectangle1Borderwidth: rectangle1.border.width + title: qsTr("Hello World") + + ListModel{ + id:sudokuModel + Component.onCompleted:{ + let board =[ + 5, 3, 0, 0, 7, 0, 0, 0, 0, + 6, 0, 0, 1, 9, 5, 0, 0, 0, + 0, 9, 8, 0, 0, 0, 0, 6, 0, + 8, 0, 0, 0, 6, 0, 0, 0, 3, + 4, 0, 0, 8, 0, 3, 0, 0, 1, + 7, 0, 0, 0, 2, 0, 0, 0, 6, + 0, 6, 0, 0, 0, 0, 2, 8, 0, + 0, 0, 0, 4, 1, 9, 0, 0, 5, + 0, 0, 0, 0, 8, 0, 0, 7, 9 + ]; + for (let i = 0; i < 81; i++) { + sudokuModel.append({ value: board[i], isFixed: board[i] !== 0 }); + } + } + } + + + Grid { + id: grid + width: 378 + height: 361 + anchors.verticalCenter: row.verticalCenter + anchors.left: row.right + anchors.right: row.left + anchors.top: row.bottom + anchors.bottom: row.top + anchors.leftMargin: -386 + anchors.rightMargin: -394 + anchors.topMargin: -418 + anchors.bottomMargin: 6 + anchors.horizontalCenter: row.horizontalCenter + spacing: 2 + rows: 3 + columns: 3 + + Repeater { + id: repeater + x: 50 + y: 60 + width: 400 + height: 600 + visible: true + model: 9 + + + Rectangle { + id: rectangle + width: 120 + height: 120 + color: "#ffffff" + border.color: "#ee040b27" + border.width: 2 + + property int blockIndex:index + Grid { + id: grid1 + x: 0 + y: 0 + width: 120 + height: 120 + spacing: 0 + rows: 3 + columns: 3 + property int blockIndex:parent.blockIndex + Repeater { + id: repeater1 + width: 120 + height: 120 + model: 9 + + Rectangle { + id: rectangle2 + width: 40 + height: 40 + color: "#ffffff" + border.width: 1 + property int globalIndex: + 1+Math.floor(parent.blockIndex / 3) * 27 + (parent.blockIndex % 3) * 3 + Math.floor(index / 3) * 9 + (index % 3) + + Text { + anchors.fill:parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + id: table_key + x: 0 + y: 0 + text:parent.globalIndex + } + + } + } + } + } + } + } + + + + + + + + Row { + id: row + x: 39 + y: 440 + width: 419 + height: 40 + spacing: 6 + + Repeater { + model: 9 + Rectangle { + width: 40 + height: 40 + color: "lightgray" + border.color: "#ee040b27" + border.width: 2 + anchors.margins: 5 // 让边框有空间显示 + + Text { + anchors.fill:parent + text: index+1 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } + } + } + + +} diff --git a/MyComponent.qml b/MyComponent.qml new file mode 100644 index 0000000000000000000000000000000000000000..645a1f2f6da413a351d09047a97af744257fce4f --- /dev/null +++ b/MyComponent.qml @@ -0,0 +1,25 @@ +import QtQuick + +Item { + id: singleBloc + width: 38 + height: 38 + property alias _textText: _text.text + x: 1 + y: 1 + focus: false + + Text { + id: _text + x: 0 + y: 0 + width: 40 + height: 40 + text: "1" + font.pixelSize: 12 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + +} diff --git a/MyTable.qml b/MyTable.qml new file mode 100644 index 0000000000000000000000000000000000000000..5560aee72760e390f8f001f3163d06bc2ed5d055 --- /dev/null +++ b/MyTable.qml @@ -0,0 +1,5 @@ +import QtQuick + +Item { + +} diff --git a/Sudoku.qrc b/Sudoku.qrc new file mode 100644 index 0000000000000000000000000000000000000000..84d0c384dce2b35a6fdcea04b10576d3350d7981 --- /dev/null +++ b/Sudoku.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>MyComponent.qml</file> + <file>MyTable.qml</file> + </qresource> +</RCC> diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..50633cea28015c3195c84fdf8ffc89f8ad80ef49 --- /dev/null +++ b/main.cpp @@ -0,0 +1,18 @@ +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + QObject::connect( + &engine, + &QQmlApplicationEngine::objectCreationFailed, + &app, + []() { QCoreApplication::exit(-1); }, + Qt::QueuedConnection); + engine.loadFromModule("suduko", "Main"); + + return app.exec(); +}