All:

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).

Attachment: delegates.tar.bz2
Description: application/bzip

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to