[Qt-interest] Qt4.4 QTextEdit size and viewport() size

Malyushytsky, Alex alex at wai.com
Sat Feb 7 00:56:27 CET 2009


Josh,

QTextEdit is derived from QAbstractScrollArea.
>From QT documentation:
>> QAbstractScrollArea is a low-level abstraction of a scrolling area. The area provides a central widget called the viewport, in which the contents of the area is to be scrolled (i.e, the visible parts of the contents are rendered in the viewport).

In other words size of the widget (viewport), the same as size of QTextEdit
is irrelevent to the size of the document.
Viewport would never increase its size because you loaded a long document into QTextEdit. What happens, it is determined which part of the document should be visible and this part is renderered in the viewport.

The size you are (probably) looking for, you can get from the scrollbars as:

int h = verticalScrollBar()->maximum () - verticalScrollBar()->minimum();

I believe this should represent the height of the document in the pixels, with rendering options (fonts, scale, etc) set for QTextEdit.


Best regards,
    Alex Malyushytsky


-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Josh
Sent: Friday, February 06, 2009 2:34 PM
To: qt-interest at trolltech.com
Subject: [Qt-interest] Qt4.4 QTextEdit size and viewport() size

Hello,

This should be simple but I can't figure it out. I have a QTextEdit with
lots of text so that scrollbars appear. I'm trying to get the size of the
widget that contains the text (for lack of a better description). I
thought the viewport() function did this, but it only returns the size of
the visible portion of the QTextEdit. The size of the QTextEdit itself
likewise is only the size of the visible widget.

So for example if you have a QTextEdit with many pages of text, the height
of the widget I'm looking for should certainly be more than the number of
pixels of the height of the screen, but both the QTextEdit's height()
function and the viewport() height() function both return the number of
pixels on the screen.

Thoughts? Ultimately it would be nice not just to get the size of the
underlying widget, but also a pointer to it itself. Thanks.

Josh
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list