[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Self-adjusting QTextEdit (PyQt4)
From:       Aaron Digulla <digulla () hepe ! com>
Date:       2008-04-27 16:55:47
Message-ID: 4814B013.9040703 () hepe ! com
[Download RAW message or body]

Wildemar Wildenburger schrieb:

>>> I'm trying to write a notecard application, somewhat in the vein of
>>> Evernote --- basically a succession of little textboxes, one per note,
>>> stacked above one another. To that end I'd like a QTextEdit (or similar)
>>> that adjusts its height (with given width) so that it always shows all
>>> its text, never more, never less.
>>>     
>> [. . .]
>>   Use QFont to find out what size the font is and then use this as a
>> fixed
>> size for your editors.
>>   
> I would have to take into account all the different fonts used, plus
> spaces and margins used by formating and images (it's rich text, after
> all), and add all that up, right?
> 
> That seems a little too much trouble to me. I should think that it
> should be fairly easy to find out the vertical size of a stream of text.
> I mean, the scrollbars seem to know . . . do they do all those
> calculations themselves? I would expect them to simply ask the text
> component "Hey, how tall are you?".

I'm not sure if the API exposes the internal widgets but the text
content is of course just a simple widget of which you can only see a
small part. The QTextEdit just builds itself from these parts (text
editor, scroll bars and a nice frame to wrap those three together).

Check the slots of the scroll bars to see how they get the visible/total
size of the scrolled area. These should be the number you're looking for.

Regards,

-- 
Aaron "Optimizer" Digulla a.k.a. Philmann Dark
"It's not the universe that's limited, it's our imagination.
Follow me and I'll show you something beyond the limits."
http://darkviews.blogspot.com/          http://www.pdark.de/
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic