Application

class qte.Application

A singleton subclass of PySide.QtGui.QApplication.

Basic usage of this class is the same as for PySide.QtGui.QApplication, but it also supports a few extra features:

  1. No arguments are specified in the constructor and sys.argv is used to construct the PySide.QtGui.QApplication object. If additional command line arguments need to be specified at runtime, then sys.argv should be modified before importing qte for the first time.

  2. It is a singleton, meaning that it only ever has one instance, and Application() always returns the same object.

  3. It recognises the main window for an application. This allows global functions, such as message, to use the main window as the parent widget.

    >>> app = Application()
    >>> win = QWidget()
    >>> app.setMainWindow(win)
    >>> app.mainWindow() is win
    True
    
  4. It is automatically created when qte is imported, to ensure that there is always a running application

  5. The application provides support for saving and restoring settings through PySide.QtGui.QSettings. PySide.QtGui.QSettings requires that the organisation and application names are set, so for convenience, the organisation is set to ‘qte’ by default. The first time Application.settings is called, a new instance of PySide.QtGui.!QSettings is created. A new instance is also created whenever it is called with arguments.

Members

New Methods

Application.addStateObject(obj, name=None)

Register an object as having a saveable state. If the object has already been added, then the name is updated.

Application.addStateObjects(objects)

Register a dict of object as having a saveable state.

Application.mainWindow()

Return the main window, or None if it has not been set.

Application.restoreGeometry(window, name=None)

Restore the window’s geometry and state. name is the section name which the settings are saved under. If it is omitted, the window’s PySide.QtCore.~QObject.objectName is used. If no settings have yet been saved, this does nothing and returns False.

Application.restoreState(obj, name=None)

Restore the objects’s state by calling PySide.QtCore.~QObject.restoreState. name is the section name which the settings are saved under. If it is omitted, the object’s PySide.QtCore.~QObject.objectName is used. If no settings have yet been saved, this does nothing and returns False.

Application.restoreStates()

Restore the state of all objects registered by addStateObject.

Application.saveGeometry(window, name=None)

Save the window’s geometry. name is the section name to save the settings under. If it is omitted, the window’s PySide.QtCore.~QObject.objectName is used.

Application.saveState(obj, name=None)

Save the object’s state by calling PySide.QtCore.~QObject.saveState. name is the section name to save the settings under. If it is omitted, the objects’s PySide.QtCore.~QObject.objectName is used.

Application.saveStates()

Save the state of all objects registered by addStateObject.

Application.setMainWindow(window)

Set the main window. window should be an instance of either PySide.QtGui.QWidget or a uiWrapper subclass. In the latter case, the actual widget wrapped is set.

Application.settings(organisation=None, application=None)

Return a PySide.QtCore.QSettings instance for this applications settings.

On the first call to this function, and every other call with arguments, a new PySide.QtCore.QSettings instance is created. If either argument is None then the application properties PySide.QtGui.~QApplication.organisationName and PySide.QtGui.~QApplication.applicationName are used. If organisation and application are omitted or None and the method has already been called, the previously created PySide.QtCore.QSettings instance is returned.

Project Versions

Table Of Contents

Previous topic

AppendProxyModel

Next topic

CheckBox

This Page