Harsh J

Memoirs of a QWERTY Keyboard

Archive for the ‘Slots’ tag

PyQt – Signals, Slots and Layouts Tutorial

18 comments

Note: If you’re new to using PyQt but are interested in great cross-platform GUI application development please read the PyQt Introduction article.

Having seen how a simple PyQt application code looks, let’s delve into user-interaction. We’ll learn about Qt’s signal-to-slot connection model for processing input and other events, and layouts for proper placement of widgets on a window.

The PyQt Class Hierarchy

PyQt is completely built upon the Object-Oriented concepts, so it is important to understand how all classes are related to each other in it.

Almost all GUI classes extend upon their Abstract class which defines common behaviour for similar widgets. These abstract classes, or any widget class, inherit QWidget, the base class of all drawable GUI components. QWidget inherits QObject, a class that has nothing to do with GUI but forms the base class of every PyQt class and helps provide the framework-related features.

The following hierarchy diagram depicts this clearly for the QPushButton class:

The QPushButton Class Hierarchy

The QPushButton Class Hierarchy

The QPaintDevice class helps draw (or paint) things on the screen, thus its also used with anything that’s drawable – We’ll learn more about Painting in a later article.

References: QWidget
Read the rest of this entry »

Written by Harsh

May 14th, 2009 at 11:37 am

Posted in Software

Tagged with , , , , ,