Nominate our 2022 Qt Champions!

MessageDialog issue

  • 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.

  • Moderators

    @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?

  • 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.

  • 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.

  • @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).


    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)
        property int xpos
        property int ypos
        property bool hold
        property bool clearCanvas:false
        Canvas {
            width: 640
            height: 410
            onPaint: {
                var ctx = getContext('2d')
                if(clearCanvas) {
                    ctx.fillStyle = "white"
                else {
                    ctx.lineWidth = 30
                    ctx.strokeStyle = 'blue'
                    xpos = area.mouseX
                    ypos = area.mouseY
                    ctx.lineTo(xpos, ypos)
            MouseArea {
                anchors.fill: parent
                acceptedButtons: Qt.LeftButton | Qt.RightButton
                onPressed: {
                    if(mouse.buttons & Qt.LeftButton) {
                        xpos = mouseX
                        ypos = mouseY
                onPositionChanged: {
                    if(hold & (mouse.buttons & Qt.LeftButton)) {
                onReleased: {
                    hold = false
        Button {
            anchors.bottom: parent.bottom
            anchors.horizontalCenter: parent.horizontalCenter
            height: 50
            width: 300
            anchors.bottomMargin: 8
            onClicked: {
                var image = canvas.getContext('2d').getImageData(0,0,canvas.width,canvas.height)
                var norm_px = []
                for(var i = 0,; i<n; i+=4) {
                    if([i]===0 &&[i+1]===0 &&[i+2]===255 &&[i+3]===255) {
                neuro.signal = norm_px
                if  (neuro.exitSignal===1) {
                    recognitionState.text="Этот символ - тэта"
                else if (neuro.exitSignal===2) {
                    recognitionState.text="Этот символ - пси"
                    recognitionState.text="Символ не распознан."
        MessageDialog {

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


    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    int main(int argc, char *argv[])
        QGuiApplication app(argc, argv);
        QQmlApplicationEngine engine;
        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.

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

  • @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.

  • @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.

  • @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.

Log in to reply