Table of Contents

Python and Qt - The Story That Gets Complex

Python version and bit Qt binding Default Used by Install Options
Python 2.7 32bit PyQt4 Qt4 my personal tools https://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.4/
Python 2.7 64bit PySide Qt4 Maya2014 64bit, Houdini v15 64bit, Nuke 10 64bit
Python 2.7 64bit PySide2 Qt5 Maya2017 64bit
Python 3.4 64bit PyQt4 Qt4 https://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.4/
Python 3.4 64bit PyQt5 Qt5 pip3 install PyQt5
Python 3.5 64bit PyQt4 Qt4 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/#pyqt4
Python 3.5 64bit PyQt5 Qt5 pip3 install PyQt5
whl https://pypi.python.org/pypi/PyQt5

Install a PythonQt binding into existing software is may be straight forward

Qt for Blender

Qt for Maya

Quick notes:

Qt UI Maya UI
push button (Buttons group) button
radio button (Buttons group) radioButton
check box(Buttons group) checkBox
combo box (containers group) optionMenu
line edit (input widgets group) textField
spin box (input widgets group) NONE
double spine box (input widgets group) NONE
dial (input widgets group) NONE
list widget (item widget item based) textScrollList
horizontal slider (input widgets) intSlider
label (display widgets group) NONE
progress bar (display widgets group) progressBar
vertical slider (input widgets) intSlider
horizontal line (input widgets) NONE
vertical line (input widgets) NONE
group box (containers group) NONE
tab widget (container group) tabLayout
main window/QWidget window

Install PythonQt binding into Operating System

install on windows

install on Mac

Complex Combo to Single Code

Write Python Code the way that work in any code

Break 1: Python 2 vs Python 3

Print Function

Run Python File

Reload module

user input module

Break 2: PySide vs PyQt

Break 3: Qt4 vs Qt5

Qt - Common Widget Code

Keystroke Detection

Visibility and Style

Visibility control

Style Sheet code

Variable Access

Connection

common connection

Python Qt multiple signal to single slot connection

Pass User Defined Function to Class Function variable holder

wip </code>

Hotkey and Shortcut

system wide hotkey

Event

Everything about Drag and Drop in Qt

Event functions
accept() set accepted flag to indicate the receiver want the event
ignore() set accepted flag off
QDropEvent functions (ref: http://doc.qt.io/qt-5/qdropevent.html)
acceptProposedAction() Sets the drop action to be the proposed action
setDropAction() set what action the receive to do with data
QtCore.Qt.CopyAction Copy the data to the target
QtCore.Qt.MoveAction Move the data to the target
QtCore.Qt.LinkAction Link the source to the target
QtCore.Qt.IgnoreAction do nothing
source() return where the drag starts, can be a widget or zero for outside Note, not all event type has source, so check the target object first
mimeData()
pos() drop position
QDragEnterEvent functions (ref:http://doc.qt.io/qt-5/qdragenterevent.html)
same as above
setDropAction() above Action option
accept() accept and allow drop event

QMimeData

Tester Getter Setter MIME Types
hasText() text() setText() text/plain
hasHtml() html() setHtml() text/html
hasUrls() urls() setUrls() text/uri-list
hasImage() imageData() setImageData() image/*
hasColor() colorData() setColorData() application/x-color
for external drag and drop (outside widget, can be from other App or other widget
my_widget.setAcceptDrops(1) will accept drop from others
my_widget.setDragEnabled(1) will allow drag starts from itself to others
for internal drag and drop
setDragDropMode(QtWidgets.QAbstractItemView.InternalMove) internally move around
setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection) individual toggle select status
setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) standard explorer type selection handling
setSelectionMode(QtWidgets.QAbstractItemView.ContiguousSelection) forced continuous selection
setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection) single select
setSelectionMode(QtWidgets.QAbstractItemView.NoSelection) no select allowed

QDrag and QMimeData

QDrag's method
setMimeData() store the mimedata
setPixmap()
setHotSpot()
exec_() start/init/exec the drag action

QThread and Threading

QNetwork

Main UI response

Simple Window

using Qt Designer ui binding for Python

Manually Code GUI

Convert ui file to Source file

compile resource like images into a py file

Dialog

Layout and Container

QWidget Property

Text Widget

Table widget

List Widget

Customize look

Tree Widget

QtCore.Qt.NoItemFlags 0 It does not have any properties set
QtCore.Qt.ItemIsSelectable 1 It can be selected
QtCore.Qt.ItemIsEditable 2 It can be edited
QtCore.Qt.ItemIsDragEnabled 4 It can be dragged
QtCore.Qt.ItemIsDropEnabled 8 It can be used as a drop target
QtCore.Qt.ItemIsUserCheckable 16 It can be checked or unchecked by the user
QtCore.Qt.ItemIsEnabled 32 The user can interact with the item
QtCore.Qt.ItemIsTristate 64 The item is checkable with three separate states

Tab Widget

QTimer Object

QtWebKit and QtNetwork

Custom Widget - Screen Grab with QLabel QRubberBand

mix Win32 and QWidget in each other

Problem and Solution

Qt - System level code

System Info

QDesktopServices

QLocale

QClipboard

QTime

File operation

QtNetwork

Reference and Tutorials

Learn from others' tool

My Words about Qt

Problem and Solution