I need to build a widget, which bases on QTextDocument
.
MyWidget.h
class MyWidget: public QFrame
{
public:
explicit MyWidget( QWidget *p_parent );
private:
QTextDocument m_textDocument;
};
MyWidget.cpp
MyWidget::MyWidget( QWidget *p_parent ) : QFrame( p_parent )
{
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setMargin( 0 );
layout->setSpacing( 0 );
m_textDocument = new QTextDocument( this );
layout->addWidget( m_textDocument ); // does not work
layout->addLayout(m_textDocument->documentLayout()); // I have tried this, but incompatible
}
I can not addWidget
because QTextDocument
is an object. How can I do to build my widget?