Hello Miko,

Thank you for answering.

> Could you be more specific about what you are trying to create? I was
> unable to understand the hierarchy of your elements i.e.:

Sure. Imagine you have a few dozen screens which all share a common base design
and have a very similar design overall (along with other characteristics). And
you have a few other dozen screens which also have the same base design but a
very different overall design compared to the other screens.

Now what I would do is: I put the common base design in BaseScreen and the more
specific design elements in SubScreens (SubScreenA, SubScreenB). Now all you 
have
to do to implement your concrete screen is to derive from SubScreenA or 
SubScreenB
and you fill them (more or less) with content. With this approach, you can 
easily
change common elements in one place - without any duplication.

Very simplified Example:

BaseScreen.qml

import QtQuick 1.1

Item {
  width: 1980
  height: 1440

  Rectangle {
    id: windowScreen
    width: parent.width
    height: parent.height

    gradient: Gradient {
      GradientStop { position: 0.5; color: "black" }
      GradientStop { position: 1.0; color: "white" }
    }
  }
}

SubScreenA.qml

import QtQuick 1.1

BaseScreen {
  Rectangle {
    id: logoBand
    
    anchors.right: parent.right

    height: parent.height
    color: "#0000FF"
  }
}

// screens derived from SubScreenB shall not contain a logoBand and have a
// overall very different layout
SubScreenB.qml

BaseScreen {
  Rectangle {
    id: menuBand
    
    anchors.top: parent.top

    width: parent.width
    color: "#0000FF"
  }
}

MainScreen.qml

SubScreenA {
  ...
}


Now the problem I am facing is this: In MainScreen for example, I cannot access 
the
anchors from the logoBand rectangle which I would need to place my content 
right next
to it with some distance. The same goes for any screen derived from SubScreenA 
where
I could not access the anchors from the menuBand rectangle.

Doing a property alias to the anchors in the SubScreenA/SubScreenB root won't 
work
because when I try to access them from a derived screen, all I get is "Cannot 
anchor
to a null item.".

I hope that cleared up my intention and problems. :)

> BaseScreen {
>   // children[0] here should point to childRect
> }

Thanks for that hint, unfortunately accessing e.g. logoBand.anchors.xxx via the
children property will yield the same error as above. :( By the way, is there 
any
way to access a child through its id name via children?

Thanks again.

So long,
Matthias

-- 
Dipl.-Inf. (FH) Matthias Dahl | Software Engineer | http://binary-island.eu
 services: custom desktop, mobile and web applications, server administration
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

Reply via email to