|  | Home · All Classes · Modules

# QtGui Module

The QtGui module extends QtCore with GUI functionality. More...

### Types

- class QAbstractButton
- class QAbstractGraphicsShapeItem
- class QAbstractItemDelegate
- class QAbstractItemView
- class QAbstractPrintDialog
- class QAbstractProxyModel
- class QAbstractScrollArea
- class QAbstractSlider
- class QAbstractSpinBox
- class QAbstractTextDocumentLayout
- class QAction
- class QActionEvent
- class QActionGroup
- class QApplication
- class QBitmap
- class QBoxLayout
- class QBrush
- class QButtonGroup
- class QCalendarWidget
- class QCheckBox
- class QClipboard
- class QCloseEvent
- class QColor
- class QColorDialog
- class QColumnView
- class QComboBox
- class QCompleter
- class QConicalGradient
- class QContextMenuEvent
- class QCursor
- class QDataWidgetMapper
- class QDateEdit
- class QDateTimeEdit
- class QDesktopServices
- class QDesktopWidget
- class QDial
- class QDialog
- class QDialogButtonBox
- class QDirModel
- class QDockWidget
- class QDoubleSpinBox
- class QDoubleValidator
- class QDrag
- class QDragEnterEvent
- class QDragLeaveEvent
- class QDragMoveEvent
- class QDropEvent
- class QErrorMessage
- class QFileDialog
- class QFileIconProvider
- class QFileOpenEvent
- class QFocusEvent
- class QFocusFrame
- class QFont
- class QFontComboBox
- class QFontDatabase
- class QFontDialog
- class QFontInfo
- class QFontMetrics
- class QFontMetricsF
- class QFrame
- class QGradient
- class QGraphicsEllipseItem
- class QGraphicsItem
- class QGraphicsItemAnimation
- class QGraphicsItemGroup
- class QGraphicsLineItem
- class QGraphicsPathItem
- class QGraphicsPixmapItem
- class QGraphicsPolygonItem
- class QGraphicsRectItem
- class QGraphicsScene
- class QGraphicsSceneContextMenuEvent
- class QGraphicsSceneDragDropEvent
- class QGraphicsSceneEvent
- class QGraphicsSceneHelpEvent
- class QGraphicsSceneHoverEvent
- class QGraphicsSceneMouseEvent
- class QGraphicsSceneWheelEvent
- class QGraphicsSimpleTextItem
- class QGraphicsTextItem
- class QGraphicsView
- class QGridLayout
- class QGroupBox
- class QHBoxLayout
- class QHeaderView
- class QHelpEvent
- class QHideEvent
- class QHoverEvent
- class QIcon
- class QIconDragEvent
- class QIconEngine
- class QIconEngineV2
- class QImage
- class QImageIOHandler
- class QImageReader
- class QImageWriter
- class QInputContext
- class QInputDialog
- class QInputEvent
- class QInputMethodEvent
- class QIntValidator
- class QItemDelegate
- class QItemEditorCreatorBase
- class QItemEditorFactory
- class QItemSelection
- class QItemSelectionModel
- class QItemSelectionRange
- class QKeyEvent
- class QKeySequence
- class QLabel
- class QLayout
- class QLayoutItem
- class QLCDNumber
- class QLinearGradient
- class QLineEdit
- class QListView
- class QListWidget
- class QListWidgetItem
- class QMainWindow
- class QMatrix
- class QMdiArea
- class QMdiSubWindow
- class QMenu
- class QMenuBar
- class QMessageBox
- class QMimeSource
- class QMouseEvent
- class QMoveEvent
- class QMovie
- class QPageSetupDialog
- class QPaintDevice
- class QPaintEngine
- class QPaintEngineState
- class QPainter
- class QPainterPath
- class QPainterPathStroker
- class QPaintEvent
- class QPalette
- class QPen
- class QPicture
- class QPictureIO
- class QPixmap
- class QPixmapCache
- class QPolygon
- class QPolygonF
- class QPrintDialog
- class QPrintEngine
- class QPrinter
- class QProgressBar
- class QProgressDialog
- class QProxyModel
- class QPushButton
- class QRadialGradient
- class QRadioButton
- class QRegExpValidator
- class QRegion
- class QResizeEvent
- class QRubberBand
- class QScrollArea
- class QScrollBar
- class QSessionManager
- class QShortcut
- class QShortcutEvent
- class QShowEvent
- class QSizeGrip
- class QSizePolicy
- class QSlider
- class QSortFilterProxyModel
- class QSound
- class QSpacerItem
- class QSpinBox
- class QSplashScreen
- class QSplitter
- class QSplitterHandle
- class QStackedLayout
- class QStackedWidget
- class QStandardItem
- class QStandardItemModel
- class QStatusBar
- class QStatusTipEvent
- class QStringListModel
- class QStyle
- class QStyleFactory
- class QStyleHintReturn
- class QStyleHintReturnMask
- class QStyleHintReturnVariant
- class QStyleOption
- class QStyleOptionButton
- class QStyleOptionComboBox
- class QStyleOptionComplex
- class QStyleOptionDockWidget
- class QStyleOptionDockWidgetV2
- class QStyleOptionFocusRect
- class QStyleOptionFrame
- class QStyleOptionFrameV2
- class QStyleOptionGraphicsItem
- class QStyleOptionGroupBox
- class QStyleOptionHeader
- class QStyleOptionMenuItem
- class QStyleOptionProgressBar
- class QStyleOptionProgressBarV2
- class QStyleOptionRubberBand
- class QStyleOptionSizeGrip
- class QStyleOptionSlider
- class QStyleOptionSpinBox
- class QStyleOptionTab
- class QStyleOptionTabBarBase
- class QStyleOptionTabV2
- class QStyleOptionTabWidgetFrame
- class QStyleOptionTitleBar
- class QStyleOptionToolBar
- class QStyleOptionToolBox
- class QStyleOptionToolBoxV2
- class QStyleOptionToolButton
- class QStyleOptionViewItem
- class QStyleOptionViewItemV2
- class QStyleOptionViewItemV3
- class QStylePainter
- class QSyntaxHighlighter
- class QSystemTrayIcon
- class QTabBar
- class QTabletEvent
- class QTableView
- class QTableWidget
- class QTableWidgetItem
- class QTableWidgetSelectionRange
- class QTabWidget
- class QTextBlock
- class QTextBlockFormat
- class QTextBlockGroup
- class QTextBlockUserData
- class QTextBrowser
- class QTextCharFormat
- class QTextCursor
- class QTextDocument
- class QTextDocumentFragment
- class QTextEdit
- class QTextFormat
- class QTextFragment
- class QTextFrame
- class QTextFrameFormat
- class QTextImageFormat
- class QTextInlineObject
- class QTextItem
- class QTextLayout
- class QTextLength
- class QTextLine
- class QTextList
- class QTextListFormat
- class QTextObject
- class QTextOption
- class QTextTable
- class QTextTableCell
- class QTextTableFormat
- class QTimeEdit
- class QToolBar
- class QToolBox
- class QToolButton
- class QToolTip
- class QTransform
- class QTreeView
- class QTreeWidget
- class QTreeWidgetItem
- class QTreeWidgetItemIterator
- class QUndoCommand
- class QUndoGroup
- class QUndoStack
- class QUndoView
- class QValidator
- class QVBoxLayout
- class QWhatsThis
- class QWhatsThisClickedEvent
- class QWheelEvent
- class QWidget
- class QWidgetAction
- class QWidgetItem
- class QWindowStateChangeEvent
- class QWizard
- class QWizardPage
- class QWorkspace
- class QX11EmbedContainer
- class QX11EmbedWidget
- class QX11Info

### Module Functions

- int qAlpha (unsigned long rgb)
- int qBlue (unsigned long rgb)
- qDrawPlainRect (QPainter p, int x, int y, int w, int h, QColor, int lineWidth = 1, QBrush fill = None)
- qDrawPlainRect (QPainter p, QRect r, QColor, int lineWidth = 1, QBrush fill = None)
- qDrawShadeLine (QPainter p, int x1, int y1, int x2, int y2, QPalette pal, bool sunken = True, int lineWidth = 1, int midLineWidth = 0)
- qDrawShadeLine (QPainter p, QPoint p1, QPoint p2, QPalette pal, bool sunken = True, int lineWidth = 1, int midLineWidth = 0)
- qDrawShadePanel (QPainter p, int x, int y, int w, int h, QPalette pal, bool sunken = False, int lineWidth = 1, QBrush fill = None)
- qDrawShadePanel (QPainter p, QRect r, QPalette pal, bool sunken = False, int lineWidth = 1, QBrush fill = None)
- qDrawShadeRect (QPainter p, int x, int y, int w, int h, QPalette pal, bool sunken = False, int lineWidth = 1, int midLineWidth = 0, QBrush fill = None)
- qDrawShadeRect (QPainter p, QRect r, QPalette pal, bool sunken = False, int lineWidth = 1, int midLineWidth = 0, QBrush fill = None)
- qDrawWinButton (QPainter p, int x, int y, int w, int h, QPalette pal, bool sunken = False, QBrush fill = None)
- qDrawWinButton (QPainter p, QRect r, QPalette pal, bool sunken = False, QBrush fill = None)
- qDrawWinPanel (QPainter p, int x, int y, int w, int h, QPalette pal, bool sunken = False, QBrush fill = None)
- qDrawWinPanel (QPainter p, QRect r, QPalette pal, bool sunken = False, QBrush fill = None)
- int qGray (int r, int g, int b)
- int qGray (unsigned long rgb)
- int qGreen (unsigned long rgb)
- bool qIsGray (unsigned long rgb)
- int qRed (unsigned long rgb)
- unsigned long qRgb (int r, int g, int b)
- unsigned long qRgba (int r, int g, int b, int a)
- qSwap (QBitmap value1, QBitmap value2)
- qSwap (QBrush value1, QBrush value2)
- qSwap (QIcon value1, QIcon value2)
- qSwap (QImage value1, QImage value2)
- qSwap (QKeySequence value1, QKeySequence value2)
- qSwap (QPen value1, QPen value2)
- qSwap (QPicture value1, QPicture value2)
- qSwap (QPixmap value1, QPixmap value2)
- qt_set_sequence_auto_mnemonic (bool enable)
- qt_x11_wait_for_window_manager (QWidget widget)

### Module Members

- QApplication qApp

## Detailed Description

The QtGui module extends QtCore with GUI functionality.

To import the module use, for example, the following statement:

    from PyQt4 import QtGui

## Function Documentation

### int qAlpha (unsigned long rgb)

Returns the alpha component of the ARGB quadruplet rgba.

See also qRgb() and QColor.alpha().

### int qBlue (unsigned long rgb)

Returns the blue component of the ARGB quadruplet rgb.

See also qRgb() and QColor.blue().

### qDrawPlainRect (QPainter p, int x, int y, int w, int h, QColor, int lineWidth = 1, QBrush fill = None)

Draws the plain rectangle beginning at (x, y) with the given width and height, using the specified painter, lineColor and lineWidth. The rectangle's interior is filled with the fill brush unless fill is 0.

Warning: This function does not look at QWidget.style() or QApplication.style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.

Alternatively you can use a QFrame widget and apply the QFrame.setFrameStyle() function to display a plain rectangle:

     QFrame frame:
     frame.setFrameStyle(QFrame.Box | QFrame.Plain);

See also qDrawShadeRect() and QStyle.

### qDrawPlainRect (QPainter p, QRect r, QColor, int lineWidth = 1, QBrush fill = None)

### qDrawShadeLine (QPainter p, int x1, int y1, int x2, int y2, QPalette pal, bool sunken = True, int lineWidth = 1, int midLineWidth = 0)

Draws a horizontal (y1 == y2) or vertical (x1 == x2) shaded line using the given painter. Note that nothing is drawn if y1 != y2 and x1 != x2 (i.e. the line is neither horizontal nor vertical).

The provided palette specifies the shading colors (light, dark and middle colors). The given lineWidth specifies the line width for each of the lines; it is not the total line width. The given midLineWidth specifies the width of a middle line drawn in the QPalette.mid() color.

The line appears sunken if sunken is true, otherwise raised.

Warning: This function does not look at QWidget.style() or QApplication.style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.

Alternatively you can use a QFrame widget and apply the QFrame.setFrameStyle() function to display a shaded line:

     QFrame frame:
     frame.setFrameStyle(QFrame.HLine | QFrame.Sunken);

See also qDrawShadeRect(), qDrawShadePanel(), and QStyle.

### qDrawShadeLine (QPainter p, QPoint p1, QPoint p2, QPalette pal, bool sunken = True, int lineWidth = 1, int midLineWidth = 0)

### qDrawShadePanel (QPainter p, int x, int y, int w, int h, QPalette pal, bool sunken = False, int lineWidth = 1, QBrush fill = None)

Draws the shaded panel beginning at (x, y) with the given width and height using the provided painter and the given lineWidth.

The given palette specifies the shading colors (light, dark and middle colors). The panel's interior is filled with the fill brush unless fill is 0.

The panel appears sunken if sunken is true, otherwise raised.

Warning: This function does not look at QWidget.style() or QApplication.style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.

Alternatively you can use a QFrame widget and apply the QFrame.setFrameStyle() function to display a shaded panel:

     QFrame frame:
     frame.setFrameStyle( QFrame.Panel | QFrame.Sunken);

See also qDrawWinPanel(), qDrawShadeLine(), qDrawShadeRect(), and QStyle.

### qDrawShadePanel (QPainter p, QRect r, QPalette pal, bool sunken = False, int lineWidth = 1, QBrush fill = None)

### qDrawShadeRect (QPainter p, int x, int y, int w, int h, QPalette pal, bool sunken = False, int lineWidth = 1, int midLineWidth = 0, QBrush fill = None)

Draws the shaded rectangle beginning at (x, y) with the given width and height using the provided painter.

The provide palette specifies the shading colors (light, dark and middle colors. The given lineWidth specifies the line width for each of the lines; it is not the total line width. The midLineWidth specifies the width of a middle line drawn in the QPalette.mid() color. The rectangle's interior is filled with the fill brush unless fill is 0.

The rectangle appears sunken if sunken is true, otherwise raised.

Warning: This function does not look at QWidget.style() or QApplication.style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.

Alternatively you can use a QFrame widget and apply the QFrame.setFrameStyle() function to display a shaded rectangle:

     QFrame frame:
     frame.setFrameStyle(QFrame.Box | QFrame.Raised);

See also qDrawShadeLine(), qDrawShadePanel(), qDrawPlainRect(), and QStyle.

### qDrawShadeRect (QPainter p, QRect r, QPalette pal, bool sunken = False, int lineWidth = 1, int midLineWidth = 0, QBrush fill = None)

### qDrawWinButton (QPainter p, int x, int y, int w, int h, QPalette pal, bool sunken = False, QBrush fill = None)

Draws the Windows-style button specified by the given point (x, y}, width and height using the provided painter with a line width of 2 pixels. The button's interior is filled with the fill brush unless fill is 0.

The given palette specifies the shading colors (light, dark and middle colors).

The button appears sunken if sunken is true, otherwise raised.

Warning: This function does not look at QWidget.style() or QApplication.style()-> Use the drawing functions in QStyle to make widgets that follow the current GUI style.

See also qDrawWinPanel() and QStyle.

### qDrawWinButton (QPainter p, QRect r, QPalette pal, bool sunken = False, QBrush fill = None)

### qDrawWinPanel (QPainter p, int x, int y, int w, int h, QPalette pal, bool sunken = False, QBrush fill = None)

Draws the Windows-style panel specified by the given point(x, y), width and height using the provided painter with a line width of 2 pixels. The button's interior is filled with the fill brush unless fill is 0.

The given palette specifies the shading colors. The panel appears sunken if sunken is true, otherwise raised.

Warning: This function does not look at QWidget.style() or QApplication.style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.

Alternatively you can use a QFrame widget and apply the QFrame.setFrameStyle() function to display a shaded panel:

     QFrame frame:
     frame.setFrameStyle(QFrame.WinPanel | QFrame.Raised);

See also qDrawShadePanel(), qDrawWinButton(), and QStyle.

### qDrawWinPanel (QPainter p, QRect r, QPalette pal, bool sunken = False, QBrush fill = None)

### int qGray (int r, int g, int b)

Returns a gray value (0 to 255) from the (r, g, b) triplet.

The gray value is calculated using the formula (r * 11 + g * 16 + b * 5)/32.

### int qGray (unsigned long rgb)

This is an overloaded member function, provided for convenience.

Returns a gray value (0 to 255) from the given ARGB quadruplet rgb.

The gray value is calculated using the formula (R * 11 + G * 16 + B * 5)/32. Note that the alpha-channel is ignored.

### int qGreen (unsigned long rgb)

Returns the green component of the ARGB quadruplet rgb.

See also qRgb() and QColor.green().

### bool qIsGray (unsigned long rgb)

### int qRed (unsigned long rgb)

Returns the red component of the ARGB quadruplet rgb.

See also qRgb() and QColor.red().

### unsigned long qRgb (int r, int g, int b)

Returns the ARGB quadruplet (255, r, g, b).

See also qRgba(), qRed(), qGreen(), and qBlue().

### unsigned long qRgba (int r, int g, int b, int a)

Returns the ARGB quadruplet (a, r, g, b).

See also qRgb(), qRed(), qGreen(), and qBlue().

### qSwap (QBitmap value1, QBitmap value2)

### qSwap (QBrush value1, QBrush value2)

### qSwap (QIcon value1, QIcon value2)

### qSwap (QImage value1, QImage value2)

### qSwap (QKeySequence value1, QKeySequence value2)

### qSwap (QPen value1, QPen value2)

### qSwap (QPicture value1, QPicture value2)

### qSwap (QPixmap value1, QPixmap value2)

### qt_set_sequence_auto_mnemonic (bool enable)

### qt_x11_wait_for_window_manager (QWidget widget)

## Member Documentation

### QApplication qApp

This member should be treated as a constant.

A global pointer referring to the unique application object. It is equivalent to the pointer returned by the QCoreApplication.instance() function except that, in GUI applications, it is a pointer to a QApplication instance.

Only one application object can be created.

See also QCoreApplication.instance().