Python Bindings for Qt (v3.0)

Phil Thompson

This document describes a set of Python bindings for the Qt widget set. Contact the author at .


Introduction

PyQt is a set of Python bindings for the Qt toolkit. They have been tested against Qt versions 1.42 to 3.0.0, Qt Non-commercial and Python versions 1.5 to 2.2b1.

The bindings are implemented as a number of Python modules

PyQt also includes the pyuic PyQt code generator used as a backend for the Qt Designer GUI design tool.

Finally, PyQt also includes a debugger called eric.

Changes

The changes visible to the Python programmer in this release are as follows.

  • The classes in Qt's Canvas module have been moved to the new qtcanvas module.

  • The classes in Qt's Network module have been moved to the new qtnetwork module.

  • The qtsql module has been added which includes the classes in Qt's SQL module.

  • The classes in Qt's Table module have been moved to the new qttable module.

  • The classes in Qt's XML module have been moved to the new qtxml module.

  • The following Qt v2 classes have been added: QColorDrag, QIconDrag, QIconDragItem, QMenuItem, QSGIStyle and QSound.

  • The following Qt v3 classes have been added: QCanvasSpline, QContextMenuEvent, QCheckTableItem, QComboTableItem, QDataBrowser, QDataTable, QDataView, QDateEdit, QDateTimeEdit, QDesktopWidget, QDockArea, QDockWindow, QEditorFactory, QErrorMessage, QGridView, QIMEvent, QKeySequence, QLibrary, QObjectCleanupHandler, QPixmapCache, QProcess, QRegExpValidator, QSettings, QSql, QSqlCursor, QSqlDatabase, QSqlDriver, QSqlEditorFactory, QSqlError, QSqlField, QSqlFieldInfo, QSqlForm, QSqlIndex, QSqlPropertyMap, QSqlQuery, QSqlRecord, QSqlRecordInfo, QSqlResult, QStyleFactory, QStyleOption, QTabletEvent, QTextEdit, QTimeEdit and QWindowsMime.

  • The following have been removed: the QTableHeader class and the QTabWidget.selected() method.

  • The following missing methods have been added: QChar.isLetterOrNumber(), QChar.mirroredChar(), QColorDialog.customColor(), QColorDialog.customCount(), QColorDialog.getRgba(), QColorDialog.setCustomColor(), QFileDialog.done(), QHeader.setUpdatesEnabled(), QHeader.showEvent(), QIconView.dropped(), QIconViewItem.dropped(), QImage.inputFormatList(), QImage.outputFormatList(), QLayoutIterator.next(), QLineEdit.displayText(), QListBox.isRubberSelecting(), QMenuBar.activateItemAt(), QMenuBar.focusInEvent(), QMenuBar.isDefaultUp(), QMenuBar.minimumSize(), QMenuBar.minimumSizeHint(), QMenuBar.setDefaultUp(), QMenuData.findItem(), QMimeSourceFactory.filePath(), QMimeSourceFactory.addFilePath(), QMotifPlusStyle.drawMenuBarItem(), QMotifPlusStyle.drawPopupMenuItem(), QMotifStyle.drawPopupMenuItem(), QMotifStyle.extraPopupMenuItemWidth(), QMotifStyle.popupMenuItemHeight(), QNetworkProtocol.newChildren(), QPainter.pos(), QPalette.inactive(), QPlatinumStyle.drawPopupMenuItem(), QPlatinumStyle.extraPopupMenuItemWidth(), QPlatinumStyle.popupMenuItemHeight(), QPopupMenu.drawItem(), QPopupMenu.itemHeight(), QPrintDialog.addButton(), QProgressDialog.forceShow(), QScrollBar.lineStep(), QScrollBar.maxValue(), QScrollBar.minValue(), QScrollBar.pageStep(), QScrollBar.setLineStep(), QScrollBar.setMaxValue(), QScrollBar.setMinValue(), QScrollBar.setPageStep(), QScrollBar.setValue(), QScrollBar.value(), QStyle.drawMenuBarItem(), QStyle.drawPopupMenuItem(), QStyle.extraPopupMenuItemWidth(), QStyle.popupMenuItemHeight(), QToolTip.hide(), QToolTipGroup.enabled(), QToolTipGroup.setEnabled(), QTranslator.messages(), QUrlOperator.newChildren(), QUrlOperator.startNextCopy(), QWindowsStyle.drawPopupMenuItem(), QWindowsStyle.extraPopupMenuItemWidth() and QWindowsStyle.popupMenuItemHeight().

  • Added all the missing methods that use QDataStream.

  • Added the missing QDir.match(), QObject.connect(), QString.append() and QString.prepend() variants.

  • Added the missing QAccel and QImage constructors.

  • The missing QString.append() and QString.prepend() variants.

  • The following missing class variables been added: QChar.nbsp.

  • The following missing functions been added: qInitNetworkProtocols().

  • The latest version of sip allows static and non-static class methods to have the same name. In previous versions the static methods were given different Python names to avoid a conflict. The affected methods have now been renamed to their correct Qt names. In particular: QDate.isValidDate() is renamed to QDate.isValid(), QTime.IsValidTime() is renamed to QTime.isValid(), QFile.fileExists() is renamed to QFile.exists() and QFile.removeFile() is renamed to QFile.remove().

  • Ownership of the QWidget parameter to QBoxLayout.addWidget(), QBoxLayout.insertWidget(), QGridLayout.addMultiCellWidget(), QGridLayout.addWidget() and QLayout.add() is no longer transfered to C++ from Python.

  • QLineEdit.del() has been renamed to QLineEdit.delChar(). QMultiLineEdit.deleteChar() has been renamed to QMultiLineEdit.delChar().

  • QObject.className() now reports the correct class name for Python classes.

  • pyuic now double-quotes strings rather than single-quotes them.