PDA

View Full Version : resize QUndoView



zack
27th August 2009, 14:39
I want to resize the a UndoView to its optimal horizontal size. That means the lenght of the biggest item (text).

I don't found a option 'resizeToContent''. So how can I achive this goal?

wysota
28th August 2009, 00:37
Retrieve size hint for the items and calculate the width needed to fit the widest item. Compensate for the decorations and margins and set that as the (minimum) width of the view. Alternatively you can guess the right size of the view by looking at the size of the viewport (through the range of the horizontal scroll bar for example).

zack
28th August 2009, 10:24
What is the viewport?

In the docs I found not much about it:

If you need to provide a scrolling view onto another widget, it may be more convenient to use the QScrollArea class because this provides a viewport widget and scroll bars.

wysota
31st August 2009, 11:31
Viewport is the part of the scroll area that actually gets scrolled. See the detailed description of QAbstractScrollArea.