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

    Felgo User

    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

    Felgo User

    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.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support