Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved QQmlApplicationEngine failed to load component

    QML and Qt Quick
    2
    5
    612
    Loading More Posts
    • 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.
    • timob256
      timob256 last edited by

      I transferred the code that renders a couple of buttons to a separate one .qml file and an error appeared

      import QtQuick 2
      import QtQuick.Window 2.2
      import QtQuick.Controls 2.12
      //import QtQuick.Controls.Styles 1.2
      import QtQuick.Layouts 1.4
      import QtQuick.Controls.Material 2.12
      
      
      Window {
      
          // вот тут переменные first tochka and dwa tochka
          property int cliced_x0 : 0;
          property int cliced_y0 : 0;
          property int cliced_x1 : 0;
          property int cliced_y1 : 0;
          property var bool_cliced : false;
      
          width: Screen.desktopAvailableWidth/1.6
          //    width: 640
          height: Screen.desktopAvailableHeight/1.6
          x:0
          y:0
          //    height: 480
          visible: true
          title: qsTr("разкройка")
      
      
      
          MyRaitRectangle{}
          MyRowLayout{}
      
          Canvas {
              id: canvas
      
              x: parent.width/3.4;
              y: parent.height/10;
      
              width: parent.width*0.6;
              height: parent.height*0.9;
      
      
      
              anchors {
                  left: parent.left
                  right: parent.right
                  top: colorTools.bottom
                  bottom: parent.bottom
                  margins: 8
              }
              property real lastX
              property real lastY
              property color color: colorTools.paintColor
      
              onPaint: {
      
                  // работает
                  var ctx = getContext('2d')
                  ctx.lineWidth = 1.5
                  ctx.strokeStyle = canvas.color
                  //            ctx.strokeStyle = "blue";
                  ctx.beginPath()
                  //            ctx.moveTo(lastX, lastY)
                  ctx.moveTo(cliced_x0, cliced_y0)
                  //            lastX = area.mouseX
                  //            lastY = area.mouseY
                  //            ctx.lineTo(lastX, lastY)
                  ctx.lineTo(cliced_x1, cliced_y1)
                  ctx.translate(cliced_x1, cliced_y1)
                  ctx.closePath()
                  ctx.stroke()
      
              }
      
              MouseArea {
                  //работатет
                  id: area
                  anchors.fill: parent
                  // моё
                  onClicked: {
      
                      if (bool_cliced == false)
                      {
                          cliced_x0 = area.mouseX;
                          cliced_y0 = area.mouseY;
                      }
                      else
                      {
                          cliced_x1 = area.mouseX;
                          cliced_y1 = area.mouseY;
                          canvas.requestPaint()
                      }
                      bool_cliced = !bool_cliced;
                  }
              }
          }
      }
      

      MyRaitRectangle{}

      import QtQuick 2.0
      import QtQuick.Window 2.2
      import QtQuick.Controls 2.12
      //import QtQuick.Controls.Styles 1.2
      import QtQuick.Layouts 1.4
      import QtQuick.Controls.Material 2.12
      
      Rectangle {
          id: rectangle
          color: "#89cdf1"
      
          x: parent.width/100;
          y:parent.height/10;
      
          width: parent.width/4
          height: parent.height/1.2
      
          Layout.alignment: Qt.AlignRight
      
          anchors
          {
              leftMargin: 10
              rightMargin: 10
              bottomMargin: 10
          }
      
      
      
          Grid{
              id: gridLayout
              x:0
              y:10;
              width:  parent.width;
              height: parent.height/3>= 120 ? parent.height/3:120;
      
      
              rows: 2
              columns: 2
              //            anchors.centerIn: parent
              columnSpacing: 10
              rowSpacing: 10
      
              Text {
                  id:text1
                  color: "#00000f"
      
                  text: "ширина1:"
                  font.family: "Helvetica"
                  font.pixelSize: parent.width/10;
              }
      
              // Область с TextInput
              Rectangle {
                  id:rectangle2
                  //                y: parent.height /100; не работает
      
                  Layout.fillWidth: true
                  Layout.fillHeight: true
                  color: "white"
                  width:  parent.width /3;
                  height:  parent.height /7;
      
                  TextInput {
                      id: textInput3
                      color: "#151515";
                      selectionColor: "green"
                      font.pixelSize: parent.width /5;
                      font.bold: true
      
                      width: parent.width/3;
                      height:  parent.height /3;
      
                      maximumLength: 8
                      anchors.centerIn: parent
                      focus: true
                      validator : RegExpValidator { regExp : /[0-9]+\.[0-9]+/ } //ввод только чисел !!
      
                      anchors.fill: parent
                      cursorVisible : true
      
      
                  }
              }
      
              Text {
                  id:text3
                  color: "#00000f"
      
                  text: "ширина2:"
                  font.family: "Helvetica"
                  //                font.pointSize: parent.width/(4*4);
                  font.pixelSize: parent.width /10;
      
              }
      
              // Область с TextInput
              Rectangle {
                  id:rectangle3
                  y:200; // не работает
                  x:100; // не работает
      
                  Layout.fillWidth: true
                  Layout.fillHeight: true
                  color: "white"
                  width:  parent.width /3;
                  height:  parent.height /7; // 10
      
                  TextInput {
                      id: textInput4
                      y: 20;
                      color: "#151515";
                      selectionColor: "green"
                      font.pixelSize: parent.width /5;
                      font.bold: true
      
                      width: parent.width/3;
                      height:  parent.height /3;
      
                      maximumLength: 8
                      anchors.centerIn: parent
                      focus: true
                      validator : RegExpValidator { regExp : /[0-9]+\.[0-9]+/ } //ввод только чисел !!
      
                      anchors.fill: parent
                      cursorVisible : true
      
                  }
              }
          }
      }
      

      MyRowLayout{}

      import QtQuick 2
      import QtQuick.Window 2.12
      import QtQuick.Controls 2.12
      import QtQuick.Layouts 1.4
      import QtQuick.Controls.Material 2.12
      
      RowLayout {
      
          id: botnes;
          anchors.horizontalCenter: parent.horizontalCenter
          z: canvas.z+1
          height:50
          anchors.horizontalCenterOffset: 0
      
      
          Button {
              id: button0
              text: qsTr("выкройка")
              display: AbstractButton.IconOnly
              ToolTip.visible: hovered
              ToolTip.text: qsTr("выкройка")
      
              Image {
                  sourceSize.width: 100
                  sourceSize.height: 40
                  anchors.fill: parent
                  //source: "file:/C:/Open_GL/razkroika/res/raskroika.png" // так работает в виндорвсе
                  sourse: "file:/home/comp/dima/qml/razkroika/res/raskroika.png" // так работает в линуксе
                //source: "qrc:/res/raskroika.png"
                // так надо но почему то не работает
                //source: "file: res/raskroika.png"
                  fillMode: Image.PreserveAspectFit
              }
      
              background: Rectangle {
                  implicitWidth: 100
                  implicitHeight: 40
                  color: button0.down ? "#ccccff" : "#bde0ff"
                  border.color: button0.down ? "#ccccff" : "#bde0ff"
                  radius: 2
              }
      
              onClicked: {
                  rectangle.visible == true ? rectangle.visible = false : rectangle.visible = true;
              }
          }
      
          Button {
              id: button1
              text: qsTr("линия")
              display: AbstractButton.IconOnly
              ToolTip.visible: hovered
              ToolTip.text: qsTr("линия")
      
              Image {
                  sourceSize.width: 100
                  sourceSize.height: 40
                  anchors.fill: parent
                  //source: "file:/C:/Open_GL/razkroika/res/linia.png" // так работает в виндорвсе
                  sourse: "file:/home/comp/dima/qml/razkroika/res/linia.png" // так работает в линуксе
                  fillMode: Image.PreserveAspectFit
              }
      
              background: Rectangle {
                  implicitWidth: 100
                  implicitHeight: 40
                  color: button1.down ? "#ccccff" : "#bde0ff"
                  border.color: button1.down ? "#ccccff" : "#bde0ff"
                  radius: 2
              }
      
              onClicked: {
                  Qt.quit();
              }
          }
      
          Button {
              id: button2
              text: qsTr("точка")
              display: AbstractButton.IconOnly
              ToolTip.visible: hovered
              ToolTip.text: qsTr("точка")
      
              Image {
                  sourceSize.width: 100
                  sourceSize.height: 40
      
                  anchors.fill: parent
      
                  //source: "file:/C:/Open_GL/razkroika/res/tochka.png" // так работает в виндорвсе
                  sourse: "file:/home/comp/dima/qml/razkroika/res/tochka.png" // так работает в линуксе
                  //source: "qrc:/res/tochka.png"
                  fillMode: Image.PreserveAspectFit
              }
      
              background: Rectangle {
                  implicitWidth: 100
                  implicitHeight: 40
                  color: button2.down ? "#ccccff" : "#bde0ff"
                  border.color: button2.down ? "#ccccff" : "#bde0ff"
                  radius: 2
              }
      
              onClicked: {
                  //   console.log("hello")
              }
          }
      
          Button {
              id: button3
              text: qsTr("радиус")
              display: AbstractButton.IconOnly
              ToolTip.visible: hovered
              ToolTip.text: qsTr("радиус")
      
              Image {
                  sourceSize.width: 100
                  sourceSize.height: 40
      
                  anchors.fill: parent
      
                  //source: "file:/C:/Open_GL/razkroika/res/radiys.png" // так работает в виндорвсе
                  sourse: "file:/home/comp/dima/qml/razkroika/res/radiys.png" // так работает в линуксе
                  //source: "qrc:/res/tochka.png"
                  fillMode: Image.PreserveAspectFit
              }
      
              background: Rectangle {
                  implicitWidth: 100
                  implicitHeight: 40
                  color: button3.down ? "#ccccff" : "#bde0ff"
                  border.color: button3.down ? "#ccccff" : "#bde0ff"
                  radius: 2
              }
      
              onClicked: {
                  //Qt.quit();
              }
          }
      }
      
      here is the output: 
      
      19:18:11: Запускается /home/comp/dima/2D/razkroika/razkroika ...
      QQmlApplicationEngine failed to load component
      qrc:/main.qml:84:5: Type MyRaitRectangle unavailable
      qrc:/MyRaitRectangle.qml:76:29: RegExpValidator is not a type
      19:18:12: /home/comp/dima/2D/razkroika/razkroika завершился с кодом 255
      
      19:19:18: Запускается /home/comp/dima/2D/razkroika/razkroika ...
      QQmlApplicationEngine failed to load component
      qrc:/main.qml:86:5: Type MyRowLayout unavailable
      qrc:/MyRowLayout.qml:32:13: Cannot assign to non-existent property "sourse"
      19:19:18: /home/comp/dima/2D/razkroika/razkroika завершился с кодом 255
      

      ![alt text](Снимок экрана от 2021-08-03 21-58-28.png image url)

      eyllanesc 1 Reply Last reply Reply Quote 0
      • eyllanesc
        eyllanesc @timob256 last edited by eyllanesc

        @timob256 TYPO: change sourse to source in sourse: "file:/home/comp/dima/qml/razkroika/res/tochka.png".

        On the other hand change import QtQuick 2.0 to import QtQuick 2.12, you are importing a very old version so that RegExpValidator is probably not available in that version.

        If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

        1 Reply Last reply Reply Quote 2
        • eyllanesc
          eyllanesc @timob256 last edited by eyllanesc

          @timob256 TYPO: change sourse to source in sourse: "file:/home/comp/dima/qml/razkroika/res/tochka.png".

          On the other hand change import QtQuick 2.0 to import QtQuick 2.12, you are importing a very old version so that RegExpValidator is probably not available in that version.

          If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

          1 Reply Last reply Reply Quote 2
          • timob256
            timob256 last edited by

            thanks , but this not work :(

                     import QtQuick 2.12
            
                    sourse: "file:/res/raskroika.png" 
            

            01:56:42: Запускается /home/comp/dima/2D/razkroika/razkroika ...
            QQmlApplicationEngine failed to load component
            qrc:/main.qml:84:5: Type MyRaitRectangle unavailable
            qrc:/MyRaitRectangle.qml:76:29: RegExpValidator is not a type
            01:56:42: /home/comp/dima/2D/razkroika/razkroika завершился с кодом 255

            ![alt text](Снимок экрана от 2021-08-05 01-59-28.png image url)

            eyllanesc 1 Reply Last reply Reply Quote 0
            • eyllanesc
              eyllanesc @timob256 last edited by

              @timob256 You have to change to import QtQuick 2.12 in all .qml, in special MyRaitRectangle.qml

              If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

              1 Reply Last reply Reply Quote 1
              • timob256
                timob256 last edited by

                @eyllanesc said in QQmlApplicationEngine failed to load component:

                import QtQuick 2.12

                import QtQuick 2.15 and import QtQuick 2.12

                RegExpValidator not work me, Ubuntu 20 (windows 7 32 bit work 0_o)

                Снимок экрана от 2021-08-05 02-50-03.png

                        source: "file:res/linia.png" // так работает в линуксе
                

                Снимок экрана от 2021-08-05 02-52-34.png

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post