Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

Forums

OverviewFelgo 2 Support (Qt 5) › Warning or Error when using Dialog {}

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #19575

    Eric

    I’m using a Dialog and am getting a warning or error depending on whether or not a specific line is added to CustomDialog.qml as described below. However, I can’t see any actual problems, everything <i>seems</i> to be working as normal, but I’d like to see if this could cause future problems. My code:

     

    SubPage.qml

    import QtQml 2.2
    import QtQuick 2.9
    import Felgo 3.0
    
    NavigationItem {
        NavigationStack {
            Page {
                ...
                AppButton {
                    text: “Button”
                    onClicked: customDialog.open()
                }
    
                CustomDialog { id: customDialog }
            }
        }
    }
    

    CustomDialog.qml

    import QtQuick 2.9
    import Felgo 3.0
    
    Dialog {
        id: customDialog
        contentHeight: parent.height * 0.8
        contentWidth: parent.width * 0.9
        anchors.verticalCenter: parent.verticalCenter
        mainWindow: App // This is the important line I think!
        onCanceled: { ... }
        onAccepted: { ... }
    
        AppFlickable {
        ...
        }
    }

     

    <b>So if mainWindow: App is added to Dialog {}</b> I get the following warnings when SubPage.qml is opened:

    qrc:///qml/VPlayApps/controls/Dialog.qml:179: QML Connections: Cannot assign to non-existant property “onBackButtonPressedGlobally”

    qrc:///qml/VPlayApps/controls/Dialog.qml:180: Unable to assign undefined to QObject*

     

    <b>If mainWindows: App is NOT added to Dialog {}</b> then I don’t get the warnings, I get the following error, but the app still functions property:

    qrc:///qml/VPlayApps/controls/Dialog.qml:311: Error: Cannot assign QObject* to Dialog_QMLTYPE_18*

     

    #19581

    Günther
    Felgo Team

    Hi,

    you state mainWindow: App, which is not a correct assignment.

    App (note uppercase ‘A’) is the component for your mainWindow.
    If you named your app with id: app, you can reference mainWindow: app in your Dialog code then.

    Best,
    Günther

    #19600

    Eric

    Thank you for your reply. I’ve tried two different options for mainWindow, “app”, and “subPage”, where subPage is the id of the SubPage.qml’s page component. If I use mainWindow: app, I get the same error as stated in the original post, “Cannot assign QObject* to Dialog_QMLTYPE_18*”

    If I use mainWindow: subPage, I get

    qrc:///qml/VPlayApps/controls/Dialog.qml:179: QML Connections: Cannot assign to non-existant property “onBackButtonPressedGlobally”.

    Am I using mainWindow incorrectly? Should I be doing something else? Do you need more information?

    Thank you.

    #19608

    Günther
    Felgo Team

    Hi,

    using mainWindow: app is the correct way, e.g.:

    import Felgo 3.0
    import QtQuick 2.9
    
    App {
      id: app
    
      AppButton {
        anchors.centerIn: parent
        text: "Open"
        onClicked: customDialog.open()
      }
    
      Dialog {
        id: customDialog
        contentHeight: parent.height * 0.8
        contentWidth: parent.width * 0.9
        anchors.verticalCenter: parent.verticalCenter
        mainWindow: app // This is the important line I think!
        onCanceled: { console.log("cancel"); customDialog.close(); }
        onAccepted: { console.log("accept"); customDialog.close(); }
    
        AppFlickable {
          AppText { text: "MyDialog" }
        }
      }
    }
    

     

    You can ignore the error “Cannot assign QObject* to Dialog_QMLTYPE_18” for now – it should not affect the usage of your Dialog.

    Best,
    Günther

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.