eulers_child
eulers_child

Reputation: 89

How can I make uniform GUI structure in qml?

I have a few application with the same structure: same topBar, same bottomBar same size of window, and other. How can I create some template or something else to exclude a lot of copy-paste?

Upvotes: 1

Views: 185

Answers (2)

Amit Tomar
Amit Tomar

Reputation: 4858

You can do something like this :

  1. Create different qml files like this -

TopBar.qml

Item
{
   // Something Something
}

BottomBar.qml

Item
{
   // Something Something
}

AppWindow.qml

Item
{
   // Something Something
}

Then, whenever you have to use these :

File1.qml

Item
{
   // Something Something
   Bottombar
   {} 
}

File2.qml

Item
{
   // Something Something
   Bottombar
   { x: 0, y: 600} 

   Topbar
   { x: 0, y: 0}

   AppWindow
   { x: 10 ; y : 50 }    
}

If you see the analogy, it is something like you created a class and then making objects of this class.

Upvotes: 0

Artur Dębski
Artur Dębski

Reputation: 34

The easiest way in my opinion will be creating a module with your common qml files

check: http://qt-project.org/doc/qt-5.0/qtqml/qtqml-modules-identifiedmodules.html

Upvotes: 1

Related Questions