Here contentsWidget has type of QWidget*. So, it really has no member function layout().
Of course it does: QWidget::layout()
Exactly which version of Qwt, which version of Qt, which platform? Post the first couple of error messages and the compiler call that produced them.