-1

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?

Community
  • 1
  • 1
Crawl.W
  • 403
  • 5
  • 17
  • Should we guess what is `DgConfigFileHandler` is? And note that `FileDialog` has no [default property](http://doc.qt.io/qt-5/qtqml-syntax-objectattributes.html#default-properties) so you cannot assign an object to it. – folibis Dec 12 '18 at 11:23
  • @folibis I do not want to assign an object, just for Instantiate a c++ class. If some qt.quick component do not support,which can, have some documentation. – Crawl.W Dec 13 '18 at 01:32
  • Did you read about default properties? You are trying to instantiate the item as a child of `FileDialog` but it doesn't support that. You have to create your item outside of `FileDialog`, that's all. – folibis Dec 13 '18 at 07:11
  • @folibis Thanks, I Know. But I think you should be more patient. As the first question in your first comment is unnecessary , if you look at my title carefully. – Crawl.W Dec 13 '18 at 09:12
  • You've asked a question without providing [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) so no one will be able to run and test it. If you expect someone to want to spend their personal time, you should do it. My first comment answer the issue, don't it? What should I be more patient about, or what does that even mean? – folibis Dec 13 '18 at 09:25
  • I receive your criticism. But this is a knowledge problem, about whether you know. So codes **run and test** is unnecessary. – Crawl.W Dec 13 '18 at 10:16

1 Answers1

0

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

Crawl.W
  • 403
  • 5
  • 17