O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Importing components

A component definition can be used directly by other QML files residing in the same directory as the component definition. In our example, the main.qml and Button.qml files are located in the same directory, so you can use the Button QML type inside main.qml without having to import anything.

If you need to access a component definition from a file residing elsewhere, you will have to first import the module containing the component in the file where you want to use it. The definition of a module is very simple—it is just a relative path to the directory containing QML files. This means that if you have a file named Baz.qml in a directory called Base/Foo/Bar and you want to use the Baz component from within the  Base/Foo/Ham.qml ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required