[PyQt] Howto use the Qt documentation successfully.

Algis Kabaila akabaila at pcug.org.au
Fri Sep 17 01:55:08 BST 2010


On Tuesday 14 September 2010 19:08:23 Hans-Peter Jansen wrote:
> Just a few words on methology:
> 
> Searching for some functionality of QTextEdit, e.g. how to get at a
> specific line via line number:
>  * Look up QTextEdit in assistant
>    We read: The QTextEdit class provides a widget that is used to edit and
>    display both plain and rich text.
>  * Click on more...
>    We read: QTextEdit works on paragraphs and characters. A paragraph is a
>    formatted string which is word-wrapped to fit into the width of the
>    widget. By default when reading plain text, one newline signifies a
>    paragraph.
>    Sounds like we're looking for paragraphs in plain text mode
>  * Check class methods, that do what we want:
>    Nothing obvious stands out
>  * Check base classes:
>    QTextEdit inherits from QAbstractScrollArea only, that won't help us
>    much here
>  * Check methods again:
>    Nothing obvious with paragraphs, but QTextDocument * document() might be
>    interesting
>  * Click on document() method:
>    We read: Returns a pointer to the underlying document.
>  * Check it out: click on QTextDocument
>    We read: The QTextDocument class holds formatted text that can be viewed
>    and edited using a QTextEdit
>    We're getting nearer, but still no ball: check out class methods
>  * It has a method: QTextBlock findBlockByLineNumber ( int lineNumber )
>    Sounds like the best fit: click on method
>  * We read: Returns the text block that contains the specified lineNumber.
>    What the hell is a QTextBlock? Click:
>    It encapsulates text fragments, and provides access to them
>  * Check methods: QString text() sounds, like what we are looking for
>    We read: Returns the block's contents as plain text.
> Target reached.
> Pete

Pete, your detailed outline is so good that I am going to save it to my 
private moin-moin wiki!

I saw a complaint in this thread (I can not find it now...) that all a newbie 
can do is to modify some existing example to adapt it to some problem at hand.  
IMHO that is about the best way to learn as long as one picks a suitable 
prototype, viz. a GUI in chapter 6 of Mark Summerfield's book!

Thank you again, Pete. 

IMO, more tutorial material could be useful.  Pete, would you encourage 
tutorials written by newbies for newbies?  

Al.

-- 
OldAl
akabaila at pcug.org.au


More information about the PyQt mailing list