I have a simple hierarchy of widgets: GraphWidget -> MotionWidget -> NodeWidget. I am new to Qt, so I am not quite sure about how some insides work yet. Basically, GraphWidget creates a single MotionWidget M and sets M's parent to itself. M then goes away and creates a bunch of NodeWidgets. However, NodeWidgets never get painted nor does their paintEvent() function gets called.
I tried creating MotionWidget directly, without GraphWidget and everything works. So why does things break if I add GraphWidget to the hierarchy?
Here is a paste with the relevant bits of code from my project. I also included the output from GraphWidget::dumpObjectTree() at the top.
Edit: forgot to include the paste link ;) http://rafb.net/p/Zp39CF94.html
Update: I wrapped MotionWidget into a layout.
Before:
GraphWidget :: GraphWidget( QWidget *parent ) : QWidget( parent )
{
setFixedSize( 500, 500 );
MotionWidget *n = new MotionWidget( 5, this );
}
After
GraphWidget :: GraphWidget( QWidget *parent ) : QWidget( parent )
{
setFixedSize( 500, 500 );
QVBoxLayout *l = new QVBoxLayout;
MotionWidget *n = new MotionWidget( 5 );
l->addWidget( n );
setLayout( l );
}
Now, the latter works. I.e. everything gets drawn. The question then becomes... Why? Why didn't it work in the first case but worked in the second?