Can't you use "QRect QFontMetrics::boundingRect ( const QString & text ) const" to get the size of the bounding box?
Pete
Can't you use "QRect QFontMetrics::boundingRect ( const QString & text ) const" to get the size of the bounding box?
Pete
skainz (20th April 2007)
It's not that simple... QFontMetrics only returns data for plaintext, while the graphics item can hold rich text.
I think this should work:
Qt Code:
//...To copy to clipboard, switch view to plain text mode
but will the document size will be valid until the window is showwn once ???
I usually use a single a shot to set the scene items based on geometries, etc. so that the correct values are used from boundingRect, document size, etc
I guess this approach is good...
ok..thx
i had actually faced a prob with initial geometries before... so i thought the same about document size![]()
No, the problems you experienced are related to the fact that widgets are laid out when they are first shown and not before. This is not the case here as the item is meant to represent the document, so knowing how big its layout is should be enough to guess the item size. Please note that you could probably just call boundingRect() and achieve the rect immediately.
Bookmarks