Hi,

I have following class (simplified...):
Qt Code:
  1. class MyLabel : public QLabel
  2. {
  3. Q_OBJECT
  4. public:
  5. explicit MyLabel(QWidget *parent = 0, Qt::WindowFlags f = 0);
  6.  
  7. protected:
  8. void paintEvent(QPaintEvent *event);
  9.  
  10. private:
  11. QPlainTextEdit *m_doc; //it is hidden, only for storing reason.
  12. };
To copy to clipboard, switch view to plain text mode 

So assume there is some content in the text edit and I do this:
Qt Code:
  1. void MyLabel::paintEvent(QPaintEvent *event)
  2. {
  3. Q_UNUSED(event);
  4. QPainter p(this);
  5. m_doc->document()->setPageSize(rect().size());
  6. m_doc->document()->drawContents(&p, rect());
  7. }
To copy to clipboard, switch view to plain text mode 
nothing is shown, but when I have this:
Qt Code:
  1. void MyLabel::paintEvent(QPaintEvent *event)
  2. {
  3. Q_UNUSED(event);
  4. QPainter p(this);
  5. QTextDocument *d = m_doc->document()->clone();
  6. d->setPageSize(rect().size());
  7. d->drawContents(&p, rect());
  8. d->deleteLater();
  9. }
To copy to clipboard, switch view to plain text mode 
everything is painted well. But why I have to clone the document??? That's not very performant... What might be the reason why I am not able to use QPlainTextEdit::document() directly?

Thanks