CecchinoSMI
CecchinoSMI

Reputation: 169

QML and Qt Creator

I designed a Qt application by Qt creator. As you well know when you build a new form is possible to drag an drop the default items inside the main window. Instead of use classical "push button" I created a custom button by adding .qml file to the project. The problem now is that I don't know how I can use (or integrate) the new button inside the form of my project.

Thanks in advance

Upvotes: 1

Views: 851

Answers (2)

rcmadruga
rcmadruga

Reputation: 847

I found this 1 year-old question when facing the same problem. This is what I found out:

If you save your custom button with an initial uppercase letter (CustomButton.qml instead of customButtom.qml), QtDesigner shows your component in the library panel correctly.

Sometimes you need to restart QtDesigner to work.

Upvotes: 1

dtech
dtech

Reputation: 49289

As long as your component is in the path of your application qml files, all you need to use your component is to place it somewhere. You don't need to include or import anything. Any user component is directly available to the entire project.

As long as the QML component is made from only built in components, it can even be safely loaded from arbitrary location on disk, over network or just from a source string. Check this answer for details on dynamic instantiation.

A friendly advice - type the code, do not use the visual editor - it is pretty weak.

EDIT: I don't know about you, but for me, seems like every custom qml file in the project qml folder is automatically added to the QML types in the designer library. So contrary to what I assumed, you shouldn't really need to do anything to get your custom type available for use in the designer.

Upvotes: 1

Related Questions