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. MessageDialog issue
Forum Updated to NodeBB v4.3 + New Features

MessageDialog issue

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
9 Posts 4 Posters 3.1k Views 2 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.
  • T Offline
    T Offline
    Tikani
    wrote on last edited by Tikani
    #1

    Hi everyone! I have a problem with launching my Windows Qt 5.7 MinGW-builded project in QtCreator.

    There is an import looks like this:

    import QtQuick 2.7
    import QtQuick.Window 2.2
    import QtQuick.Dialogs 1.2
    import QtQuick.Controls 2.0
    
    

    And I have a MessageDialog in my main.qml to implement typical modal MessageBox. After successful project building, when I try to launch my program in QtCreator context, application log shows:

    QQmlApplicationEngine failed to load component
    qrc:/main.qml:129 ??? ?MessageDialog? ??????????
    qrc:/QtQuick/Dialogs/DefaultMessageDialog.qml:41 ?????? ?QtQuick.Controls? ?????? 1.2 ?? ??????????
    
    

    Okay, let's check DefaultMessageDialog.qml out:

    import QtQuick.Controls 1.2
    
    

    I cannot remove QtQuick.Controls 2.0 from my main.qml because of using Button object on the form.

    Honourable experts, what should I do with these two conflicting imports of different versions? Please, help.

    CharlieGC 1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @Tikani What are the question marks ?
      Also can you import QtQuick.Controls 2.0 before import QtQuick.Dialogs 1.2 and see if the same error persists?

      157

      T 1 Reply Last reply
      1
      • T Tikani

        Hi everyone! I have a problem with launching my Windows Qt 5.7 MinGW-builded project in QtCreator.

        There is an import looks like this:

        import QtQuick 2.7
        import QtQuick.Window 2.2
        import QtQuick.Dialogs 1.2
        import QtQuick.Controls 2.0
        
        

        And I have a MessageDialog in my main.qml to implement typical modal MessageBox. After successful project building, when I try to launch my program in QtCreator context, application log shows:

        QQmlApplicationEngine failed to load component
        qrc:/main.qml:129 ??? ?MessageDialog? ??????????
        qrc:/QtQuick/Dialogs/DefaultMessageDialog.qml:41 ?????? ?QtQuick.Controls? ?????? 1.2 ?? ??????????
        
        

        Okay, let's check DefaultMessageDialog.qml out:

        import QtQuick.Controls 1.2
        
        

        I cannot remove QtQuick.Controls 2.0 from my main.qml because of using Button object on the form.

        Honourable experts, what should I do with these two conflicting imports of different versions? Please, help.

        CharlieGC Offline
        CharlieGC Offline
        CharlieG
        wrote on last edited by
        #3

        Hi @Tikani,

        There are Button in QtQuick.Controls 1.4... Maybe you can use this ?

        If no, have you try this import import QtQuick.Controls 1.4 as ControlA ?

        To finish, try with creating yourte dialog in other QML document, for example MyDialog.qml where you don't import QtQuick.Controls 2.0.

        T 2 Replies Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Hi! Don't invest too much work in a "nice" solution, we get new Quick Controls 2 dialogs with Qt 5.8, see: New Features in 5.8, Qt 5.8 Release.

          1 Reply Last reply
          1
          • p3c0P p3c0

            @Tikani What are the question marks ?
            Also can you import QtQuick.Controls 2.0 before import QtQuick.Dialogs 1.2 and see if the same error persists?

            T Offline
            T Offline
            Tikani
            wrote on last edited by Tikani
            #5

            @p3c0 I don't know what the question marks are since I simply copy-pasted here the contents of application log panel. I guess it is due to lack of debug information (however, it is strange, because I built the project with chosen "Debug" configuration in the bottom-left corner).

            main.qml

            import QtQuick 2.7
            import QtQuick.Window 2.2
            import QtQuick.Controls 2.0
            import QtQuick.Dialogs 1.2
            
            
            Window {
                visible: true
                width: 640
                height: 480
                maximumHeight: height
                maximumWidth: width
                minimumHeight: height
                minimumWidth: width
                color: "white"
                title: "Однослойный перцептрон"
            
                Component.onCompleted: {
                    setX(Screen.width/2 - width/2)
                    setY(Screen.height/2 - height/2)
                    neuro.loadWeights()
                }
            
                property int xpos
                property int ypos
                property bool hold
                property bool clearCanvas:false
            
                Canvas {
                    id:canvas
                    anchors.top: parent.top
                    width: 640
                    height: 410
            
            
                    onPaint: {
                        var ctx = getContext('2d')
            
                        if(clearCanvas) {
                            ctx.fillStyle = "white"
                            ctx.fillRect(0,0,width,height)
                            clearCanvas=false
            
                        }
                        else {
                            ctx.lineWidth = 30
                            ctx.strokeStyle = 'blue'
                            ctx.beginPath()
                            ctx.moveTo(xpos,ypos)
                            xpos = area.mouseX
                            ypos = area.mouseY
                            ctx.lineTo(xpos, ypos)
                            ctx.stroke()
                        }
                    }
            
                    MouseArea {
                        id:area
                        anchors.fill: parent
                        acceptedButtons: Qt.LeftButton | Qt.RightButton
            
                        onPressed: {
                            if(mouse.buttons & Qt.LeftButton) {
                                hold=true
                                xpos = mouseX
                                ypos = mouseY
                            }
                        }
            
                        onPositionChanged: {
                            if(hold & (mouse.buttons & Qt.LeftButton)) {
                                canvas.requestPaint()
                            }
            
                        }
            
                        onReleased: {
                            hold = false
                        }
            
            
                    }
                }
            
                Button {
                    id:recognize
                    anchors.bottom: parent.bottom
                    anchors.horizontalCenter: parent.horizontalCenter
                    height: 50
                    width: 300
                    anchors.bottomMargin: 8
                    text:"Распознать"
            
                    onClicked: {
                        var image = canvas.getContext('2d').getImageData(0,0,canvas.width,canvas.height)
                        var norm_px = []
            
                        for(var i = 0, n=image.data.length; i<n; i+=4) {
                            if(image.data[i]===0 && image.data[i+1]===0 && image.data[i+2]===255 && image.data[i+3]===255) {
                                norm_px.push(1)
                            }
                            else
                            {
                                norm_px.push(0)
                            }
                        }
            
                        neuro.signal = norm_px
            
                        neuro.calculate()
            
                        if  (neuro.exitSignal===1) {
                            recognitionState.text="Этот символ - тэта"
                        }
                        else if (neuro.exitSignal===2) {
                            recognitionState.text="Этот символ - пси"
                        }
                        else
                            recognitionState.text="Символ не распознан."
            
                        recognitionState.open()
            
                        canvas.requestPaint()
                        clearCanvas=true
                    }
            
                }
            
                MessageDialog {
                    id:recognitionState
                    title:"Классификация"
                    icon:StandardIcon.Information
                }
            
            
            }
            

            Here I have changed the imports according to your advice but I get the same error.

            main.cpp

            #include <QGuiApplication>
            #include <QQmlApplicationEngine>
            
            int main(int argc, char *argv[])
            {
                QGuiApplication app(argc, argv);
            
                QQmlApplicationEngine engine;
            
                engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
            
                return app.exec();
            }
            
            

            I suspect that error occurs when QQmlApplicationEngine looks through main.qml resolving dependencies recursively of given objects and when it reaches MessageDialog then it gets 2 conflicting imports. I've tried to import QtQuick.Controls 1.2 in main.qml but it gives nothing.

            1 Reply Last reply
            0
            • CharlieGC CharlieG

              Hi @Tikani,

              There are Button in QtQuick.Controls 1.4... Maybe you can use this ?

              If no, have you try this import import QtQuick.Controls 1.4 as ControlA ?

              To finish, try with creating yourte dialog in other QML document, for example MyDialog.qml where you don't import QtQuick.Controls 2.0.

              T Offline
              T Offline
              Tikani
              wrote on last edited by
              #6

              @CharlieG Unfortunately, namespace tricks didn't help :( I'll try the last variant you suggested.

              1 Reply Last reply
              0
              • CharlieGC CharlieG

                Hi @Tikani,

                There are Button in QtQuick.Controls 1.4... Maybe you can use this ?

                If no, have you try this import import QtQuick.Controls 1.4 as ControlA ?

                To finish, try with creating yourte dialog in other QML document, for example MyDialog.qml where you don't import QtQuick.Controls 2.0.

                T Offline
                T Offline
                Tikani
                wrote on last edited by
                #7

                @CharlieG Your last variant hasn't helped too. I will try to craft "homemade" MessageBox by combining Popup and Rectangle. Hope it can be a solution in my case.

                1 Reply Last reply
                0
                • CharlieGC Offline
                  CharlieGC Offline
                  CharlieG
                  wrote on last edited by
                  #8

                  @Tikani, I've tested your code and I don't have this problem on Mac OS X (build is correct). But I can't make a full test beacause it's missing neuro.

                  T 1 Reply Last reply
                  0
                  • CharlieGC CharlieG

                    @Tikani, I've tested your code and I don't have this problem on Mac OS X (build is correct). But I can't make a full test beacause it's missing neuro.

                    T Offline
                    T Offline
                    Tikani
                    wrote on last edited by Tikani
                    #9

                    @CharlieG You can download my project from Github and test it. You need ANN project.
                    P.S. When I built this project under Linux everything was OK too. I get this error on Windows only.

                    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