[PyKDE] Some fundamentals
boud at valdyas.org
Tue Feb 25 07:52:00 GMT 2003
-----BEGIN PGP SIGNED MESSAGE-----
On Tuesday 25 February 2003 01:13, Tom Chance wrote:
> I've only just started out with PyQt, so please bear with me as I ask some
> boring questions :)
> I've been reading through the book "GUI Programming with Python: QT
> Edition" by Boudewijn Rempt online (the paper copy is just too expensive
> for a poorly student like me :-), and though it covers a lot of ground,
> it's written in a very confusing order, jumping around between ideas.
I guess it doesn't help that the online version misses all screenshots
and the helpful titlepages between sections. Start with
http://www.opendocs.org/pyqt/index.lxp?lxpwrap=c1036%2ehtm, that shows
how to write a simple script to start with.
> Anyway, enough rambling. I'm using Qt Designer to create my GUI, and I'm
> then importing the class in my main program file. At the moment, the main
> program file contains one class that inherits the GUI class, and that
> contains all my functions. I'm sure this isn't the best way to do things -
> I'm used to creating multiple classes, each one for a different task, and
> it seems a little messy having all my function code in one class. What's
> the best way of laying out the code?
Doesn't matter much. You don't even need to inherit the gui class; there
are cases where simple instantiation is enough, if you connect the signals
from the gui class widgets to slots in your own code.
> Also, I'm struggling with connecting signals and slots. I understand the
> principle, and I'm getting the hang of working wiht Qt Designer and my code
> to create empty functions in Designer, and then create the actual functions
> in my main code, but I don't really understand the signal parameter in a
> E.g. I can guess what "pressed(QListViewItem*)" means? But why the
> QListViewItem with an asterisk? And what really confuses me is the "int,
> const Qstring&" stuff. What do they signify, and why are they in the signal
> for a rightButtonClicked(), whilst clicked() has no parameters, and pressed
> only has QListViewItem?
The signal parameter from C++ signals is a simple name. In C++, the parameters
define the kind of data passed to the slot; but in Python it's simply used to
distinguish between signals with the same name but different parameter lists.
The funny things, like int, & and * are simply copied from C++, where they
denote the type of parameter. They're present in the Python bindings because
it makes it easier to use the Qt C++ docs.
> Back to the docs for now!
You might also want to take a look at the tutorial I wrote for Dr Dobbs
(January 2001 issue), which covers the first steps and principles, but in
a lot less detail than the book.
Boudewijn Rempt | http://www.valdyas.org/index2.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
-----END PGP SIGNATURE-----
More information about the PyQt