On creation, scene->height() is zero by default. If ruler->setFixedHeight() unwittingly set the height of the ruler to 0, paintEvent for the ruler will not be called.
void setScene(QGraphicsScene* scene)
{
QGraphicsView::setScene(scene);
if (scene)
ruler->setFixedHeight(scene->height());
}