Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy QWidget::paintEvent doesn't get called?
    primarykey
    data
    text
    <p>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 <em>M</em> and sets <em>M's</em> parent to itself. <em>M</em> then goes away and creates a bunch of NodeWidgets. However, NodeWidgets never get painted nor does their paintEvent() function gets called.</p> <p>I tried creating MotionWidget directly, without GraphWidget and everything works. So why does things break if I add GraphWidget to the hierarchy?</p> <p>Here is a paste with the relevant bits of code from my project. I also included the output from GraphWidget::dumpObjectTree() at the top.</p> <p>Edit: forgot to include the paste link ;) <a href="http://rafb.net/p/Zp39CF94.html" rel="nofollow noreferrer">http://rafb.net/p/Zp39CF94.html</a></p> <p>Update: I wrapped MotionWidget into a layout.</p> <p>Before:</p> <pre><code>GraphWidget :: GraphWidget( QWidget *parent ) : QWidget( parent ) { setFixedSize( 500, 500 ); MotionWidget *n = new MotionWidget( 5, this ); } </code></pre> <p>After</p> <pre><code>GraphWidget :: GraphWidget( QWidget *parent ) : QWidget( parent ) { setFixedSize( 500, 500 ); QVBoxLayout *l = new QVBoxLayout; MotionWidget *n = new MotionWidget( 5 ); l-&gt;addWidget( n ); setLayout( l ); } </code></pre> <p>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?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload