As we have seen earlier, the central area of the QMainWindow
can be occupied by any kind of widget. This widget can be any of the following:
Qt
widget such as QTextEdit
or QGraphicsView
QWidget
with a layout manager, which acts as a parent for many other widgetsQSplitter
which arranges the widgets horizontally or verticallyIn our example, we use QTextEdit
as the central widget. The PySide.QtGui.QTextEdit
class provides a widget that is used to edit and display both plain and rich text formats. QTextEdit
is an advanced WYSIWYG viewer/editor supporting rich text formatting using HTML style tags. It can display text, images, lists, and tables as well. The rich text support in Qt
is designed to provide a fast, portable, and efficient way to add reasonable online help facilities to applications, and to provide a basis for rich text editors. The QTextEdit
can be both used as a display widget and an editor. For our purposes, we use it as an editor.
The following piece of code sets the QTextEdit
as the central widget. On calling this function from main
block by using the QApplication
object, a text editor will be set at the central space of our application. The output is shown in the screenshot following the information box containing the code excerpt: