Creating a dock widget
All the panels in QGIS are dock widgets. These widgets can attach to a side of the main window or float freely in a separate window. These panels can contain any other type of widget, which is why they are usually the interface for QGIS plugins. In this recipe, we'll create a dock widget with a text editor widget inside.
Getting ready
Open the QGIS Python console by selecting the Plugins menu and then clicking on Python Console.
How to do it...
We'll create a QTextEdit widget. Then we'll create a QDockWidget and place the QTextEdit
widget inside it. Finally we'll display the dock widget in the main window:
- First, we import the Qt libraries, which contain all the widgets:
from PyQt4.QtCore import * from PyQt4.QtGui import *
Get QGIS Python Programming Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.