### Qt Configuration and Setup Source: https://github.com/cneben/quickqanava/blob/develop/samples/groups/CMakeLists.txt Configures Qt6, requiring core, Quick, Qml, and QuickControls2 components. Sets up standard project settings and C++ standards. ```cmake # Configure Qt find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml Quick QuickControls2) qt_standard_project_setup(REQUIRES 6.6) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) ``` -------------------------------- ### Initialize QuickQanava in QML Source: https://github.com/cneben/quickqanava/blob/develop/doc/web/docs/advanced.md This QML snippet demonstrates the basic setup for QuickQanava within an ApplicationWindow, including importing the library and defining a GraphView with an associated Graph component. ```qml import QuickQanava 2.0 as Qan import "qrc:/QuickQanava" as Qan ApplicationWindow { title: "QuickQanava cpp API" Qan.GraphView { anchors.fill: parent graph : Qan.Graph { objectName: "graph" anchors.fill: parent } // Qan.Graph: graph } } ``` -------------------------------- ### Install QuickQanava as a Git Submodule Source: https://github.com/cneben/quickqanava/blob/develop/doc/web/docs/installation.md Use these commands to add QuickQanava as a Git submodule to your project and update it. ```sh $ git submodule add https://github.com/cneben/QuickQanava * git submodule update ``` -------------------------------- ### Build QuickQanava Samples with CMake (CI) Source: https://github.com/cneben/quickqanava/blob/develop/doc/web/docs/installation.md Manually build QuickQanava and its samples using CMake. Configure Qt installation path if not automatically detected. Samples are located in ./samples after build. ```sh $ cd QuickQanava $ mkdir build $ cd build # IF QT_DIR IS CONFIGURED AND QMAKE IN PATH $ cmake -DCMAKE_BUILD_TYPE=Release -DQUICK_QANAVA_BUILD_SAMPLES=OFF .. # IF QT DIR IS NOT CONFIGURED, CONFIGURE KIT MANUALLY $ cmake -DCMAKE_PREFIX_PATH="/path/to/Qt/5.15.14/gcc_64" -DQT_QMAKE_EXECUTABLE="/path/to/Qt/6.6.1/gcc_64/bin/qmake" -DQUICK_QANAVA_BUILD_SAMPLES=OFF ../QuickQanava/ $ cmake --build . # Then run the samples in ./samples # There is no make install ``` -------------------------------- ### CMake Project Setup Source: https://github.com/cneben/quickqanava/blob/develop/samples/groups/CMakeLists.txt Initializes the CMake project, specifying the minimum required version, project name, version, and C++ language standard. ```cmake cmake_minimum_required(VERSION 3.16) project(QuickQanava_sample_groups VERSION 2.5.0 LANGUAGES CXX) ``` -------------------------------- ### Clone QuickQanava Repository Source: https://github.com/cneben/quickqanava/blob/develop/doc/BUILDING.md Use this command to get the latest QuickQanava sources from GitHub. ```sh git clone https://github.com/cneben/QuickQanava cd QuickQanava ``` -------------------------------- ### Initialize QuickQanava QML Engine in C++ Source: https://github.com/cneben/quickqanava/blob/develop/doc/web/docs/advanced.md This C++ code initializes the QML engine and QuickQanava, then loads the main QML file. Ensure this is done before starting the application event loop. ```cpp // main.cpp int main(int argc, char** argv) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; QuickQanava::initialize(&engine); // Mandatory engine.load(QUrl("qrc:/main.qml")); // Custom "synchronous" topology initialization should be added here return app.exec(); } ``` -------------------------------- ### Configure Build with Specific Qt Path and CMake Source: https://github.com/cneben/quickqanava/blob/develop/doc/BUILDING.md Manually configure the build using CMake, specifying the Qt installation path and disabling sample builds. Also enables building static QRC resources. ```sh cmake -DCMAKE_PREFIX_PATH="/home/xxx/Qt/6.6.1/gcc_64" -DQUICK_QANAVA_BUILD_SAMPLES=OFF -DBUILD_STATIC_QRC=TRUE ../QuickQanava/ ``` -------------------------------- ### Initialize QuickQanava in main.cpp Source: https://context7.com/cneben/quickqanava/llms.txt Call QuickQanava::initialize() once in main() before loading QML to register all Qan types and prepare default delegates. ```cpp // main.cpp #include #include #include #include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); QQuickStyle::setStyle("Material"); QQmlApplicationEngine engine; QuickQanava::initialize(&engine); // Required — registers all Qan types engine.load(QUrl("qrc:/main.qml")); return app.exec(); } ``` -------------------------------- ### Insert and Bind Ports and Edges Source: https://context7.com/cneben/quickqanava/llms.txt Demonstrates how to add output and input ports to nodes and then connect them with an edge. Shows how to remove a port. ```qml Qan.Graph { id: graph Component.onCompleted: { var n1 = graph.insertNode(); n1.label = "Producer" n1.item.x = 50; n1.item.y = 150 var n2 = graph.insertNode(); n2.label = "Consumer" n2.item.x = 400; n2.item.y = 150 // Add an output port on the right of n1 var outPort = graph.insertPort(n1, Qan.NodeItem.Right) outPort.label = "OUT" // Add an input port on the left of n2 var inPort = graph.insertPort(n2, Qan.NodeItem.Left) inPort.label = "IN" // Connect via ports var e = graph.insertEdge(n1, n2) graph.bindEdgeSource(e, outPort) graph.bindEdgeDestination(e, inPort) // Remove a port graph.removePort(n1, outPort) } } ``` -------------------------------- ### Link Libraries Source: https://github.com/cneben/quickqanava/blob/develop/samples/edges/CMakeLists.txt Links the necessary libraries for the sample executable, including QuickQanava, its plugin, and core Qt modules. ```cmake target_link_libraries(sample_edges_exe PRIVATE QuickQanava QuickQanavaplugin Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::QuickControls2 ) ``` -------------------------------- ### Import QuickQanava in main.qml Source: https://context7.com/cneben/quickqanava/llms.txt Import the QuickQanava QML module after initialization. ```qml // main.qml — import after initialization import QuickQanava 2.0 as Qan import "qrc:/QuickQanava" as Qan ``` -------------------------------- ### QuickQanava::initialize() Source: https://context7.com/cneben/quickqanava/llms.txt Initializes the QuickQanava library by registering all QML types and preparing default delegates. This function must be called once in main() before any QuickQanava components are loaded by the QML engine. ```APIDOC ## QuickQanava::initialize() — Library Initialization Must be called once in `main()` before the QML engine loads any QuickQanava components. Registers all QML types and prepares default delegates. ```cpp // main.cpp #include #include #include #include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); QQuickStyle::setStyle("Material"); QQmlApplicationEngine engine; QuickQanava::initialize(&engine); // Required — registers all Qan types engine.load(QUrl("qrc:/main.qml")); return app.exec(); } ``` ```qml // main.qml — import after initialization import QuickQanava 2.0 as Qan import "qrc:/QuickQanava" as Qan ``` ``` -------------------------------- ### Link QuickQanava in CMakeLists.txt Source: https://context7.com/cneben/quickqanava/llms.txt Link the QuickQanava library and include its directories in your CMakeLists.txt file. ```cmake # CMakeLists.txt add_subdirectory(QuickQanava) target_link_libraries(my_project QuickQanava Qt6::Core Qt6::Gui Qt6::QuickControls2 ) target_include_directories(my_project PUBLIC QuickQanava Qt6::QuickControls2) ``` -------------------------------- ### Standalone Resize Handle Utility (C++ Registration) Source: https://context7.com/cneben/quickqanava/llms.txt Register `qan::BottomRightResizer` and its variants (`qan::RightResizer`, `qan::BottomResizer`) in C++ for use outside of QuickQanava. ```cpp // C++ registration for use outside of QuickQanava: qmlRegisterType("YourModule", 1, 0, "BottomRightResizer"); // Also available: qan::RightResizer, qan::BottomResizer ``` -------------------------------- ### Integrate QuickQanava with CMake Source: https://github.com/cneben/quickqanava/blob/develop/doc/web/docs/installation.md Add QuickQanava as a subdirectory in your CMakeLists.txt and link against it. Ensure Qt6 is configured. ```cmake add_subdirectory(PATH_TO_QUICKQANAVA_SUBMODULE) target_include_directories(my_project PUBLIC QuickQanava Qt${QT_VERSION_MAJOR}::QuickControls2) target_link_libraries(sample_advanced QuickQanava Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::QuickControls2 ) ``` -------------------------------- ### Add QuickQanava as Git Submodule Source: https://context7.com/cneben/quickqanava/llms.txt Add QuickQanava as a Git submodule to your project and update it. ```sh # Add as a Git submodule git submodule add https://github.com/cneben/QuickQanava git submodule update ``` -------------------------------- ### Add QuickQanava as Git Submodule Source: https://github.com/cneben/quickqanava/blob/develop/doc/BUILDING.md Integrate QuickQanava into your project as a Git submodule. ```sh $ git submodule add https://github.com/cneben/QuickQanava $ git submodule update ``` -------------------------------- ### Initialize QuickQanava in C++ Source: https://github.com/cneben/quickqanava/blob/develop/doc/web/docs/graph.md QuickQanava must be initialized in your C++ main function before loading QML. This ensures the library is properly set up for use. ```cpp #include int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQuickStyle::setStyle("Material"); QQmlApplicationEngine engine; // Or in a custom QQuickView constructor: QuickQanava::initialize(); engine.load( ... ); return app.exec(); } ``` -------------------------------- ### Attach Custom Node Behaviour to a Node (C++) Source: https://github.com/cneben/quickqanava/blob/develop/doc/web/docs/advanced.md Demonstrates how to instantiate and attach a custom `qan::NodeBehaviour` to a `qan::Node` instance, enabling the node to observe and react to incoming node insertions and removals. ```cpp { qan::Graph graph; auto node = graph.insertNode(); node->attachBehaviour(std::make_unique()); // node will now react when an in node is inserted or removed auto source = graph.insertNode(); auto edge = graph.insertEdge(source, node); // CustomBehaviour::Inserted() called graph.removeEdge(edge); // CustomBehaviour::inNodeRemoved() called } ``` -------------------------------- ### Define Executable and QML Module Source: https://github.com/cneben/quickqanava/blob/develop/samples/edges/CMakeLists.txt Defines the main executable for the sample and creates a QML module for integrating QML files into the application. ```cmake qt_add_executable(sample_edges_exe edges.cpp) qt_add_qml_module(SampleEdges VERSION 1.0 URI SampleEdges QML_FILES SampleEdges.qml Endings.qml Curved.qml Ortho.qml OUTPUT_DIRECTORY SampleEdges ) ``` -------------------------------- ### Configure Qan.LineGrid for Graph Background Source: https://context7.com/cneben/quickqanava/llms.txt Set up a background grid on the graph view with configurable scale, major line frequency, width, and color. ```qml Qan.GraphView { anchors.fill: parent graph: Qan.Graph { id: graph gridThickColor: "lightgrey" grid: Qan.LineGrid { gridScale: 50 // Pixels between grid lines gridMajor: 5 // Every 5th line is a major (thicker) line gridWidth: 1 // Line width in pixels thickColor: "#c0c0c0" } } } ``` -------------------------------- ### Insert and Bind Ports to Nodes and Edges Source: https://github.com/cneben/quickqanava/blob/develop/doc/web/docs/nodes.md Shows how to insert input and output ports on a node and then bind an edge to these specific ports for controlled connections. ```javascript Component.onCompleted: { // Qan.Graph.Component.onCompleted() var n3 = graph.insertNode() n3.label = "N3"; n3.item.x = 500; n3.item.y = 100 var n3p1 = graph.insertInPort(n3, Qan.NodeItem.Left); n3p1.label = "IN #1" var n3p1 = graph.insertInPort(n3, Qan.NodeItem.Top); n3p1.label = "OUT #1" var n3p2 = graph.insertInPort(n3, Qan.NodeItem.Bottom); n3p2.label = "OUT #2" var e = graph.insertEdge(n2, n3) graph.bindEdgeDestination(e, n2p3) // Bind our edge source to node N2 port P3 (OUT #1) graph.bindEdgeDestination(e, n3p1) // Bind our edge destination to node N3 port P1 (IN #1) } ``` -------------------------------- ### Minimal Qan.Graph with Nodes and Edge Source: https://context7.com/cneben/quickqanava/llms.txt Create a minimal graph with two nodes and one edge using Qan.Graph. Nodes and edges are inserted and configured, and topology is queried. ```qml // Minimal graph with two nodes and one edge import QuickQanava 2.0 as Qan Qan.GraphView { anchors.fill: parent navigable: true graph: Qan.Graph { id: graph anchors.fill: parent Component.onCompleted: { var n1 = graph.insertNode() n1.label = "Source" n1.item.x = 50; n1.item.y = 100 var n2 = graph.insertNode() n2.label = "Destination" n2.item.x = 300; n2.item.y = 100 var e = graph.insertEdge(n1, n2) e.label = "My Edge" // Query topology console.log("Node count:", graph.getNodeCount()) console.log("Edge count:", graph.getEdgeCount()) } onNodeClicked: (node) => console.log("Clicked:", node.label) onNodeRightClicked: (node, pos) => console.log("Right-clicked:", node.label) onEdgeClicked: (edge) => console.log("Edge clicked:", edge.label) } } ``` -------------------------------- ### Configure Node Resizing Behavior Source: https://github.com/cneben/quickqanava/blob/develop/doc/web/docs/nodes.md Illustrates how to disable or enable node resizing and set a specific aspect ratio for resizing using Qan.NodeItem properties. ```javascript Component.onCompleted: { // Qan.Graph.Component.onCompleted() var n1 = graph.insertNode() n1.item.resizable = false // n1 is not resizable var n2 = graph.insertNode() n2.item.resizable = true // n2 is resizable (setting to true is // not mandatory, it's the default behaviour) n2.item.ratio = 0.5 // node resizing will maintain a width/height ratio // of 0.5, ie height will alays be half of width. } ``` -------------------------------- ### Material Styling Integration for QuickQanava Source: https://github.com/cneben/quickqanava/blob/develop/doc/web/docs/styles.md Integrates QuickQanava UI elements with Qt Quick Controls 2 Material themes to support light and dark modes. Ensure necessary imports for Material and QuickQanava. ```cpp import QtQuick.Controls.Material 2.1 import QuickQanava 2.0 as Qan import "qrc:/QuickQanava" as Qan Qan.GraphView { resizeHandlerColor: Material.accent gridThickColor: Material.theme === Material.Dark ? "#4e4e4e" : "#c1c1c1" topology: Qan.Graph { // ... selectionColor: Material.accent connectorColor: Material.accent connectorEdgeColor: Material.accent // ... } // Qan.Graph // ... } // Qan.GraphView ``` -------------------------------- ### Target Library Linking Source: https://github.com/cneben/quickqanava/blob/develop/samples/groups/CMakeLists.txt Links the executable target with necessary libraries, including QuickQanava, its plugin, and core Qt modules. ```cmake target_link_libraries(sample_groups_exe PRIVATE QuickQanava QuickQanavaplugin Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::QuickControls2 ) ``` -------------------------------- ### Configure Release Build with CMake Source: https://github.com/cneben/quickqanava/blob/develop/doc/BUILDING.md Configure the build with CMake for a Release build type, disabling sample builds. Assumes QT_DIR is configured. ```sh cmake -DCMAKE_BUILD_TYPE=Release -DQUICK_QANAVA_BUILD_SAMPLES=OFF .. ``` -------------------------------- ### Build Project with CMake Source: https://github.com/cneben/quickqanava/blob/develop/doc/BUILDING.md Build the project using CMake after configuration. This command should be run from the build directory. ```sh cmake --build . ``` -------------------------------- ### Interactive Qan.GraphView Configuration Source: https://context7.com/cneben/quickqanava/llms.txt Configure Qan.GraphView for interactive use, enabling panning, zooming, and customizing visual elements like resize handler and grid colors. The 'Fit' button demonstrates fitting content to the view. ```qml import QtQuick.Controls.Material 2.1 import QuickQanava 2.0 as Qan Qan.GraphView { id: graphView anchors.fill: parent navigable: true // Enable pan/zoom (default true) resizeHandlerColor: Material.accent // Corner resize handler color gridThickColor: Material.theme === Material.Dark ? "#4e4e4e" : "#c1c1c1" graph: Qan.Graph { id: topology anchors.fill: parent selectionColor: Material.accent connectorEnabled: true connectorColor: Material.accent connectorEdgeColor: Material.accent } // Fit all graph content into view Button { text: "Fit" onClicked: graphView.fitContentInView() } } ``` -------------------------------- ### Executable and QML Module Definition Source: https://github.com/cneben/quickqanava/blob/develop/samples/groups/CMakeLists.txt Defines the source files for the executable and creates a QML module with specified version, URI, and QML files. ```cmake set(source_files groups.cpp ) qt_add_executable(sample_groups_exe groups.cpp) qt_add_qml_module(SampleGroups VERSION 1.0 URI SampleGroups QML_FILES SampleGroups.qml OUTPUT_DIRECTORY SampleGroups ) ``` -------------------------------- ### Configure Project and Qt Source: https://github.com/cneben/quickqanava/blob/develop/samples/edges/CMakeLists.txt Sets the minimum CMake version, project name, and version. Configures Qt6 components and standard project settings, including C++ standard and compiler flags. ```cmake cmake_minimum_required(VERSION 3.16) project(QuickQanava_sample_edges VERSION 2.5.0 LANGUAGES CXX) # Configure Qt find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml Quick QuickControls2) qt_standard_project_setup(REQUIRES 6.6) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:QT_QML_DEBUG>) set(CMAKE_INCLUDE_CURRENT_DIR ON) ``` -------------------------------- ### Non-Visual Nodes and Edges (C++) Source: https://context7.com/cneben/quickqanava/llms.txt Demonstrates how to insert non-visual nodes and edges into a QuickQanava graph using C++. These elements are useful for internal graph logic without requiring a visual representation. ```APIDOC ## Non-Visual Nodes and Edges (C++) — `insertNonVisualNode<>()` / `insertNonVisualEdge<>()` Insert topology primitives that have no QML visual counterpart, useful for modelling internal graph logic without rendering overhead. ```cpp qan::Graph graph; // Insert a non-visual node (no delegate created) auto* logicNode = graph.insertNonVisualNode(); // Insert a non-visual directed edge between two existing nodes auto* src = graph.insertNode(); auto* dst = graph.insertNode(); auto* hiddenEdge = graph.insertNonVisualEdge(src, dst); // Hyper edge: node → edge (oriented hyper-edge) auto* hyperEdge = graph.insertNonVisualEdge(src, hiddenEdge); ``` ``` -------------------------------- ### Create Default Group and Nodes in Qan.Graph Source: https://github.com/cneben/quickqanava/blob/develop/doc/web/docs/nodes.md Demonstrates inserting nodes, edges, and a default group into a Qan.Graph. Configures group dimensions and label. ```cpp Qan.Graph { id: graph objectName: "graph" anchors.fill: parent Component.onCompleted: { var n1 = graph.insertNode() n1.label = "N1" var n2 = graph.insertNode() n2.label = "N2" var n3 = graph.insertNode() n3.label = "N3" graph.insertEdge(n1, n2) graph.insertEdge(n2, n3) var gg = graph.insertGroup(); gg.item.preferredGroupWidth = 300. gg.item.preferredGroupHeight = 250. gg.item.minimumGroupWidth = 200. gg.item.minimumGroupHeight = 150. gg.label = "Group" } } // Qan.Graph: graph ``` -------------------------------- ### Iterate Selected Nodes in C++ Source: https://context7.com/cneben/quickqanava/llms.txt Shows how to iterate through the currently selected nodes in a Qanava graph using C++. ```cpp // C++ — iterate current selection auto& graph = *myGraph; for (const auto* node : qAsConst(graph.getSelectNodes())) { if (node != nullptr) qDebug() << "Selected:" << node->getLabel(); } ``` -------------------------------- ### Resource File Inclusion Source: https://github.com/cneben/quickqanava/blob/develop/samples/groups/CMakeLists.txt Adds Qt resource files to the executable, specifying a prefix and the files to include. ```cmake qt6_add_resources(sample_groups_exe "controls_conf" PREFIX "/" FILES "qtquickcontrols2.conf" ) ``` -------------------------------- ### Standalone Resize Handle Utility (QML) Source: https://context7.com/cneben/quickqanava/llms.txt Attach a corner drag handle to any `QQuickItem` for visual resizing using `Qan.BottomRightResizer`. This utility can be used independently of QuickQanava's graph components. ```qml import QuickQanava 2.0 as Qan Item { id: myResizableBox width: 200; height: 150 Rectangle { anchors.fill: parent; color: "lightsteelblue"; radius: 6 } // Attach resizer to the bottom-right corner of this item Qan.BottomRightResizer { target: myResizableBox } } ``` -------------------------------- ### Include Directories and Resources Source: https://github.com/cneben/quickqanava/blob/develop/samples/edges/CMakeLists.txt Adds include directories for the project and Qt resources. This ensures that necessary headers and QML files are accessible during the build process. ```cmake include_directories(${CMAKE_CURRENT_SOURCE_DIR} "../../src") qt6_add_resources(sample_edges_exe "controls_conf" PREFIX "/" FILES "qtquickcontrols2.conf" ) ``` -------------------------------- ### Implement Node Topology Observation with C++ Source: https://context7.com/cneben/quickqanava/llms.txt Attach custom C++ behavior objects to nodes using `qan::NodeBehaviour` to react to topological changes like edge insertion or removal. Ensure your behavior class inherits from `qan::NodeBehaviour` and overrides relevant virtual methods. ```cpp #include class MyBehaviour : public qan::NodeBehaviour { Q_OBJECT public: explicit MyBehaviour(QObject* parent = nullptr) : qan::NodeBehaviour{"My Behaviour", parent} {} virtual ~MyBehaviour() override = default; MyBehaviour(const MyBehaviour&) = delete; protected: virtual void inNodeInserted(qan::Node& inNode, qan::Edge& edge) noexcept override { qDebug() << "In-node connected:" << inNode.getLabel(); } virtual void inNodeRemoved(qan::Node& inNode, qan::Edge& edge) noexcept override { qDebug() << "In-node disconnected:" << inNode.getLabel(); } }; // Attach behaviour to a node qan::Graph graph; auto* node = graph.insertNode(); auto* source = graph.insertNode(); node->attachBehaviour(std::make_unique()); auto* edge = graph.insertEdge(source, node); // Triggers inNodeInserted() graph.removeEdge(edge); // Triggers inNodeRemoved() ``` -------------------------------- ### Define Custom Node Delegate and Style (C++) Source: https://github.com/cneben/quickqanava/blob/develop/doc/web/docs/advanced.md Implement the `delegate()` method to specify the QML component for a custom node and the `style()` method to define its default visual properties, such as background color. ```cpp CustomRectNode_delegate = std::make_unique(&engine, "qrc:/MyNode.qml"); return CustomRectNode_delegate.get(); } qan::NodeStyle* MyNode::style() noexcept { static std::unique_ptr MyNode_style; if (!MyNode_style) { MyNode_style = std::make_unique(); MyNode_style->setBackColor(QColor("#ff29fc")); // Initialize primitive default style here } return MyNode_style.get(); } ``` -------------------------------- ### Use Tree and Random Layouts in QuickQanava Source: https://context7.com/cneben/quickqanava/llms.txt Employ Qan.OrgTreeLayout for hierarchical arrangements and Qan.RandomLayout for scattering nodes. Trigger layouts from UI elements like buttons. OrgTreeLayout supports Vertical, Horizontal, and Mixed orientations. ```qml Qan.GraphView { graph: Qan.Graph { id: graph Qan.OrgTreeLayout { id: orgLayout } Qan.RandomLayout { id: randomLayout layoutRect: Qt.rect(50, 50, 1000, 800) } Component.onCompleted: { let root = graph.insertNode(); root.label = "Root" let c1 = graph.insertNode(); c1.label = "Child 1" let c2 = graph.insertNode(); c2.label = "Child 2" let gc1 = graph.insertNode(); gc1.label = "Grandchild" graph.insertEdge(root, c1) graph.insertEdge(root, c2) graph.insertEdge(c1, gc1) } } // Trigger layout from UI Button { text: "Vertical Tree" onClicked: { orgLayout.layoutOrientation = Qan.OrgTreeLayout.Vertical orgLayout.layout(graph.getNodeAt(0)) // Pass tree root node } } Button { text: "Random" onClicked: randomLayout.layout(undefined) } } ``` -------------------------------- ### Qan.LineGrid Configuration Source: https://context7.com/cneben/quickqanava/llms.txt Configures a background grid drawn on the graph view canvas. Supports configurable scale, major thick lines, line width, and color. ```APIDOC ## `Qan.LineGrid` — Graph Grid Overlay Configures a background grid drawn on the graph view canvas. Set on `Qan.Graph.grid`. Supports configurable scale, major thick lines, line width, and color. ```qml Qan.GraphView { anchors.fill: parent graph: Qan.Graph { id: graph gridThickColor: "lightgrey" grid: Qan.LineGrid { gridScale: 50 // Pixels between grid lines gridMajor: 5 // Every 5th line is a major (thicker) line gridWidth: 1 // Line width in pixels thickColor: "#c0c0c0" } } } ``` ``` -------------------------------- ### Configure Graph Selection Policy Source: https://context7.com/cneben/quickqanava/llms.txt Sets the graph's selection policy to 'SelectOnClick' and configures visual selection properties. Also demonstrates how to disable selection on individual nodes. ```qml Qan.Graph { id: graph // Policies: Qan.Graph.NoSelection | SelectOnClick | SelectOnCtrlClick selectionPolicy: Qan.Graph.SelectOnClick selectionColor: "dodgerblue" selectionWeight: 3.0 selectionMargin: 4.0 // Disable selection on a specific node Component.onCompleted: { var n = graph.insertNode() n.item.selectable = false // This node cannot be selected } } ``` ```qml // Display selection in a QML list ListView { model: graph.selectedNodes delegate: Text { text: "Selected: " + itemData.label } } ``` -------------------------------- ### Import QuickQanava in QML Source: https://github.com/cneben/quickqanava/blob/develop/doc/web/docs/graph.md Import the QuickQanava module in your QML files to use its components. This allows you to integrate graph functionalities into your QML applications. ```qml import QuickQanava 2.0 as Qan import "qrc:/QuickQanava" as Qan ```