Instantiate a c++ class in FileDialog (QtQuick Object), report error: Cannot assign object to property

111 views Asked by At

Codes:

//main.qml
import im.sniper.DgConfigFileHandler 1.0
import QtQuick.Dialogs 1.2
...
FileDialog{
    id: fileDlg
    DgConfigFileHandler {id: dgCfgFileHandler2}
}

I complie codes well and run, then get errors like:

QML debugging is enabled. Only use this in a safe environment.(Crawl: That's a another problem, you can ignore)

QQmlApplicationEngine failed to load component

qrc:/main.qml:22 Cannot assign object to property

And another component like Page, Window, Button, can Instantiate the C++ class. What's wrong?

1

There are 1 answers

0
Crawl.W On

That's because some components inherits Item which own containers, which can be used for storage FileDialog. See the official documentation for details, Item QML Type's property data.And FileDialog can be added any Item-based type implicitly for Default Properties(as @folibis referred to).