I'm trying to make a container, similar to GridView. I can set a delegate and create instances of them, but I can't seem to make them visible. What am I doing wrong?
To illustrate my problem, I've set up a minimal example (attached) with a custom Component called "FourSquare." It's supposed to lay out four of the delegates in a 2x2 grid. The expected results of the program is to see 4 red squares. However, I don't see them... all I see is the background.
void FourSquare::update_layout()
{
int rows, cols, r, c;
int x, y, m;
QObject *obj;
if (!m_delegate)
return;
rows = 2;
cols = 2;
m = 2; /* margin */
y = 0;
for (r = 0 ; r < rows ; ++r) {
x = 0;
for (c = 0 ; c < cols ; ++c) {
if (!m_children[r][c]) {
obj = m_delegate->create();
obj->setParent(this);
}
obj->setProperty("x", x);
obj->setProperty("y", y);
obj->setProperty("width", m_cellWidth);
obj->setProperty("height", m_cellHeight);
x += m_cellWidth + m;
}
y += m_cellHeight + m;
}
}
Thanks in advance!
-gabriel
p.s. I'm using Qt 4.7.4 on Ubuntu 11.10 (x86).
Of course you can change "this" by the pointer to the desired QDeclarativeItem
if needed.
Good luck!
PS: I have seen tha you used obj->setParent(QObject*) but I don't think this
has some effect on QML rendering.
--
Unai IRIGOYEN
Ingénieur
Mail: u.iri...@gmail.com
Tel: +33 (0)6 10 68 50 15
Profils sociaux professionnels:
Viadeo: http://wwww.viadeo.com/fr/profile/unai.irigoyen
LinkedIn: http://fr.linkedin.com/in/irigoyenunai
_______________________________________________
Interest mailing list
Inte...@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
That did the trick! Thanks!
-gabriel