[Qt-jambi-interest] a problem about QGraphicsTextItem----help
Gunnar Sletta
gunnar at trolltech.com
Thu Jul 31 08:26:29 CEST 2008
?? wrote:
> QGraphicsView gv=new QGraphicsView();
> QGraphicsScene gs=new QGraphicsScene();
> QGraphicsTextItem textitem=new QGraphicsTextItem();
> textitem.setDocument(ui.textEdit.document());
> gs.addItem(textitem);
> gv=new QGraphicsView(gs);
> gv.show();
> ***********************************************code
> above***************************************
>
>
> I want use this to view the rich text in the "ui.textEdit", but the
> QGraphicsView doesn't show the QGraphicsTextItem with the QTextDocument.
> What's wrong with it?
>
> And after that, I tried to change the
> "textitem.setDocument(ui.textEdit.document());" into
> "textitem.setHtml(ui.textEdit.toHtml());" and then it really works well
> without problem.
>
> I need the setDocument function to archive my rich text (including
> images) viewer in my project.
> Please help me.
> Thanks a lot in deed.
Hi,
It seems the document is not valid until you either force do a layout on
it using adjustSize() or until the QTextEdit is shown. If you do either
the above should work.
best regards,
Gunnar
More information about the Qt-jambi-interest
mailing list