-
Python Qt Slot Decorator카테고리 없음 2021. 1. 14. 13:42
This is the reference guide for PyQt 4.3.1. PyQt v4 is a set ofPython bindings for v4 of the Qt applicationframework from Trolltech.
There is a separate PyQt API Reference.
Add an object whose slots will be used as decorator slots for other QObjects or CPP classes. The slots need to follow the convention that the first argument is a pointer to the wrapped object. (ownership is passed to PythonQt). Very simple and intuitive. For more information on Python decorators, you might want to checkout the article - Python Decorators Overview to familiarise yourself. Finally, let's instantiate a Circle, hook up the signals to the slots, and move and resize it.
Qt is a set of C++ libraries and development tools that includes platformindependent abstractions for graphical user interfaces, networking, threads,Unicode, regular expressions, SQL databases, SVG, OpenGL, XML, and user andapplication settings. PyQt implements 440 of these classes as a set ofPython modules.
- The signal on its own does not perform any action. Instead, it is ‘connected’ to a ‘slot’. The slot can be any callable Python function. In PyQt, connection between a signal and a slot can be achieved in different ways. Following are most commonly used techniques − QtCore.QObject.connect(widget, QtCore.SIGNAL(‘signalname’), slot.
- You will find the designer in the site-packages/pyqt5tools directory of your Python environment and should be available in your PATH as designer or pyqt5designer. These packages will also provide pyuic5 for converting Designer files to Python files. It also includes many other utilities like qdbus, qdoc, qmlscene, linguist, and more.
- This time, using the @Signal decorator instead of instantiating a Signal object. We also provide a setter slot, setMaxNumber with a Qt name (camelCase) that simply calls the Python method setmaxnumber alongside a getter with a Python name. Again, the setter emits the change signal when the value is.
PyQt supports the Windows, Linux, UNIX and MacOS/X platforms.
PyQt does not include Qt itself - you must obtain it separately.
The homepage for PyQt is http://www.riverbankcomputing.co.uk/pyqt/. Here youwill always find the latest stable version, current development snapshots, andthe latest version of this documentation.
PyQt is built using the SIP bindings generator. SIP must be installed in orderto build and use PyQt.
Earlier versions of Qt are supported by PyQt v3.
1.1 License
Like Qt v4, PyQt is licensed on all platforms under a commercial license andthe GPL v2. Your PyQt license must be the same as your Qt license, ie. useeither the commercial versions of both or the GPL versions of both. If youuse the GPL versions then your own code must also be licensed under the GPL.
You can purchase a commercial PyQt license here.
1.2 PyQt Components
PyQt comprises a number of different components. First of all there are anumber of Python extension modules. These are all installed in the PyQt4Python package.
- The QtCore module. This contains the core non-GUI classes, includingthe event loop and Qt's signal and slot mechanism. It also includesplatform independent abstractions for Unicode, threads, regularexpressions, and user and application settings.
- The QtGui module. This contains the majority of the GUI classes.
- The QtNetwork module. This module contains classes for writing UDPand TCP clients and servers. It includes classes that implement FTP andHTTP clients and support DNS lookups.
- The QtOpenGL module. This module contains classes that enable theuse of OpenGL in rendering 3D graphics in PyQt applications.
- The QtScript module. This module contains classes that enable PyQtapplications to be scripted using Qt's JavaScript interpreter.
- The QtSql module. This module contains classes that integrate withSQL databases. It includes editable data models for database tables thatcan be used with GUI classes. It also includes an implementation ofSQLite.
- The QtSvg module. This module contains classes for displaying thecontents of SVG files.
- The QtTest module. This module contains functions that enable unittesting of PyQt applications. (PyQt does not implement the complete Qtunit test framework. Instead it assumes that the standard Python unittest framework will be used and implements those functions that simulatea user interacting with a GUI.)
- The QtXml module. This module contains classes that implement SAXand DOM interfaces to Qt's XML parser.
- The QtAssistant module. This module contains classes that allow QtAssistant to be integrated with a PyQt application to provide onlinehelp.
- The QtDesigner module. This module contains classes that allow QtDesigner to be extended using PyQt. See Writing Qt Designer Pluginsfor a full description of how to do this.
- The QAxContainer module. This module contains classes that allowaccess to ActiveX controls and COM objects. It is only available in thecommercial version of PyQt for Windows.
- The Qt module. This module consolidates the classes contained in allof the modules described above into a single module. This has theadvantage that you don't have to worry about which underlying modulecontains a particular class. It has the disadvantage that it loads thewhole of the Qt framework, thereby increasing the memory footprint of anapplication. Whether you use this consolidated module, or the individualcomponent modules is down to personal taste.
- The DBus supportmodule is installed as dbus.mainloop.qt. PyQt does not support Qt'snative DBus classes (which are very C++ orientated). Instead thedbus.mainloop.qt` module provides support for the Qt event loop in thesame way that the dbus.mainloop.glib` included with the standarddbus-python bindings package provides support for the GLib eventloop. The API is described in The DBus Support Module. It is onlyavailable for PyQt for X11 and only if the dbus-python v0.80 (orlater) bindings package is installed.
- The uic module. This module contains classes for handling the.ui files created by Qt Designer that describe the whole or part of agraphical user interface. It includes classes that load a .ui fileand render it directly, and classes that generate Python code from a.ui file for later execution. It is covered in detail in The uicModule.
- The pyqtconfig module is an extention of the SIP build system and iscreated when PyQt is configured. It encapsulates all the necessaryinformation about your Qt installation and makes it easier to writeinstallation scripts for bindings built on top of PyQt. It is coveredin detail in The PyQt Build System.
PyQt also contains a number of utility programs.
- pyuic4 corresponds to the Qt uic utility. It converts GUIscreated using Qt Designer to Python code. It is covered in detail inpyuic4.
- pyrcc4 corresponds to the Qt rcc utility. It embeds arbitraryresources (eg. icons, images, translation files) described by a resourcecollection file in a Python module. It is covered in detail inpyrcc4. (Note It will only be included if your copy of Qt includesthe XML module.)
- pylupdate4 corresponds to the Qt lupdate utility. It extractsall of the translatable strings from Python code and creates or updates.ts translation files. These are then used by Qt Linguist to managethe translation of those strings. It is covered in detail inpylupdate4. (Note It will only be included if your copy of Qtincludes the XML module.)
Python Qt Slot Decorator Tool
When PyQt is configured a file called PyQt4.api is generated. This can beused by the QScintilla editor component (athttp://www.riverbankcomputing.co.uk/qscintilla/) to enable the use ofauto-completion and call tips when editing PyQt code. The API file isinstalled automatically if QScintilla is already installed.
Python Qt Install
PyQt includes a large number of examples. These are ports to Python of manyof the C++ examples provided with Qt. They can be found in the examplesdirectory.
Python Qt Designer Slot
Finally, PyQt contains the .sip files used by SIP to generate PyQtitself. These can be used by developers of bindings of other Qt based classlibraries - for example PyQwt and PyQwt3D.