Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. error: ninja: build stopped: subcommand failed.
Forum Updated to NodeBB v4.3 + New Features

error: ninja: build stopped: subcommand failed.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 402 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qcoderpro
    wrote on last edited by qcoderpro
    #1

    This is my example (Qt 6.4.3)
    main.qml:

    import QtQuick
    DocumentQML { visible: true }
    

    DocumentQML.qml:

    import QtQuick
    import QtQuick.Controls
    import Qt.labs.platform as NativeDialog
    
    ApplicationWindow {
        id: root
        title: (fileName.length === 0 ? "Document" : filename) + isDirty ? "*" : ""
        width: 800
        height: 600
    
        property bool isDirty: true
        property string fileName
        property bool tryingToClose: false
    
        menuBar: MenuBar {
               Menu {
                   title: qsTr("&File")
                   MenuItem {
                       text: qsTr("&New")
                       icon.name: "document-new"
                       onTriggered: root.newDocument()
                   }
                   MenuSeparator {}
                   MenuItem {
                       text: qsTr("&Open")
                       icon.name: "document-open"
                       onTriggered: openDocument()
                   }
                   MenuItem {
                       text: qsTr("&Save")
                       icon.name: "document-save"
                       onTriggered: saveDocument()
                   }
                   MenuItem {
                       text: qsTr("Save &As...")
                       icon.name: "document-save-as"
                       onTriggered: saveAsDocument()
                   }
               }
           }
    
    
        function createNewDocument() {
            var component = Qt.createComponent("DocumentWindow.qml");
            var window = component.createObject();
            return window;
        }
    
        function NewDocument() {
            var window = createNewDocument();
            window.show();
        }
    
        function openDocument() {
            openDialog.open();
        }
    
        function saveAsDocument() {
            saveAsDialog.open();
        }
    
        function saveDocument() {
            if(fileName.length === 0)
                root.saveAsDocument();
            else {
                 // Save document here
                console.log("Saving document")
                root.isDirty = false;
    
                if(root.tryingToClose)
                    root.close();
            }
        }
    
        NativeDialog.FileDialog {
            id: openDialog
            title: "Open"
            folder: NativeDialog.StandardButton.writableLocation(
                        NativeDialog.StandardPaths.DocumentsLocation)
            onAccepted: {
                var window = root.createNewDocument();
                window.fileName = openDialog.file();
                window.show();
            }
        }
        NativeDialog.FileDialog {
            id:saveAsDialog
            title: "Save as"
            folder: NativeDialog.StandardPaths.writableLocation(
                        NativeDialog.StandardPaths.DocumentsLocation)
    
            onAccepted : {
                root.fileName = saveAsDialog.file
                saveDocument();
            }
            onRejected: root.tryingToClose = false;
        }
    
    
    
        onClosing: if(root.isDirty) {
                closeWarningDialog.open();
                close.accepted = false;
            }
    
        NativeDialog.MessageDialog {
            id: closeWarningDialog
            title: "Cloasing document"
            text: "You have unsaved changes. Do you want to save your changes?"
            buttons: NativeDialog.MessageDialog.Yes | NativeDialog.MessageDialog.No
            | NativeDialog.MessageDialog.Cancel
    
            onYesClicked: {
                // Attempt to save the document
                root.tryingToClose = true
                root.saveDocument();
            }
            onNoClicked: {
                // Close the window
                root.isDirty = false
                root.close()
            }
    
            onReject: {/* do nothing */ }
        }
    }
    

    CMakeLists.txt:

    cmake_minimum_required(VERSION 3.16)
    
    project(QML_3 VERSION 0.1 LANGUAGES CXX)
    
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
    
    qt_standard_project_setup(REQUIRES 6.5)
    
    qt_add_executable(appQML_3
        main.cpp
    )
    
    qt_add_qml_module(appQML_3
        URI QML_3
        VERSION 1.0
        QML_FILES Main.qml
        DocumentQML.qml
    )
    
    set_target_properties(appQML_3 PROPERTIES
        MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
        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(appQML_3
        PRIVATE Qt6::Quick
    )
    
    install(TARGETS appQML_3
        BUNDLE DESTINATION .
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    )
    

    When run, I get this error:
    error: ninja: build stopped: subcommand failed.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved