Skip to content

PythonQt.QtGui.QSessionManager · declarations 001

Back to PythonQt.QtGui.QSessionManager

RestartAnyway instance-attribute

RestartAnyway: Any

RestartHint instance-attribute

RestartHint: type

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal.

int('0b100', base=0) 4

RestartIfRunning instance-attribute

RestartIfRunning: Any

RestartImmediately instance-attribute

RestartImmediately: Any

RestartNever instance-attribute

RestartNever: Any

allowsErrorInteraction

allowsErrorInteraction() -> bool

X.allowsErrorInteraction() -> bool

Supplemental documentation: Qt 5 reference:

bool QSessionManager::allowsErrorInteraction()

Returns true if error interaction is permitted; otherwise returns false.

This is similar to allowsInteraction(), but also enables the application to tell the user about any errors that occur. Session managers may give error interaction requests higher priority, which means that it is more likely that an error interaction is permitted. However, you are still not guaranteed that the session manager will allow interaction.

See also allowsInteraction(), release(), and cancel().

Upstream PySide2 reference signatures (binding differences may apply):

allowsErrorInteraction(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qsessionmanager.html#allowsErrorInteraction

allowsInteraction

allowsInteraction() -> bool

X.allowsInteraction() -> bool

Supplemental documentation: Qt 5 reference:

bool QSessionManager::allowsInteraction()

Asks the session manager for permission to interact with the user. Returns true if interaction is permitted; otherwise returns false.

The rationale behind this mechanism is to make it possible to synchronize user interaction during a shutdown. Advanced session managers may ask all applications simultaneously to commit their data, resulting in a much faster shutdown.

When the interaction is completed we strongly recommend releasing the user interaction semaphore with a call to release(). This way, other applications may get the chance to interact with the user while your application is still busy saving data. (The semaphore is implicitly released when the application exits.)

If the user decides to cancel the shutdown process during the interaction phase, you must tell the session manager that this has happened by calling cancel().

Here's an example of how an application's QGuiApplication::commitDataRequest() might be implemented:

MyMainWidget::MyMainWidget(QWidget *parent)
    :QWidget(parent)
{
    QGuiApplication::setFallbackSessionManagementEnabled(false);
    connect(qApp, &QGuiApplication::commitDataRequest,
            this, &MyMainWidget::commitData);
}

void MyMainWidget::commitData(QSessionManager& manager)
{
    if (manager.allowsInteraction()) {
        int ret = QMessageBox::warning(
                    mainWindow,
                    tr("My Application"),
                    tr("Save changes to document?"),
                    QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);

        switch (ret) {
        case QMessageBox::Save:
            manager.release();
            if (!saveDocument())
                manager.cancel();
            break;
        case QMessageBox::Discard:
            break;
        case QMessageBox::Cancel:
        default:
            manager.cancel();
        }
    } else {
        // we did not get permission to interact, then
        // do something reasonable instead
    }
}

If an error occurred within the application while saving its data, you may want to try allowsErrorInteraction() instead.

See also QGuiApplication::commitDataRequest(), release(), and cancel().

Upstream PySide2 reference signatures (binding differences may apply):

allowsInteraction(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qsessionmanager.html#allowsInteraction

cancel

cancel() -> None

X.cancel()

Supplemental documentation: Qt 5 reference:

void QSessionManager::cancel()

Tells the session manager to cancel the shutdown process. Applications should not call this function without asking the user first.

See also allowsInteraction() and allowsErrorInteraction().

Upstream PySide2 reference signatures (binding differences may apply):

cancel(self) -> None

Source: https://doc.qt.io/archives/qt-5.15/qsessionmanager.html#cancel

destroyed

destroyed(*args: Any, **kwargs: Any) -> Any

Native PythonQt.QtGui.QSessionManager.destroyed; argument details are not documented.

discardCommand

discardCommand() -> tuple

X.discardCommand() -> tuple

Supplemental documentation: Qt 5 reference:

QStringList QSessionManager::discardCommand() const

Returns the currently set discard command.

To iterate over the list, you can use the foreach pseudo-keyword:

const QStringList commands = mySession.discardCommand();
for (const QString &command : mySession.discardCommand())
    do_something(command);

See also setDiscardCommand(), restartCommand(), and setRestartCommand().

Upstream PySide2 reference signatures (binding differences may apply):

discardCommand(self) -> typing.List[str]

Source: https://doc.qt.io/archives/qt-5.15/qsessionmanager.html#discardCommand

isPhase2

isPhase2() -> bool

X.isPhase2() -> bool

Supplemental documentation: Qt 5 reference:

bool QSessionManager::isPhase2() const

Returns true if the session manager is currently performing a second session management phase; otherwise returns false.

See also requestPhase2().

Upstream PySide2 reference signatures (binding differences may apply):

isPhase2(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qsessionmanager.html#isPhase2

objectNameChanged

objectNameChanged(*args: Any, **kwargs: Any) -> Any

Native PythonQt.QtGui.QSessionManager.objectNameChanged; argument details are not documented.

release

release() -> None

X.release()

Supplemental documentation: Qt 5 reference:

void QSessionManager::release()

Releases the session manager's interaction semaphore after an interaction phase.

See also allowsInteraction() and allowsErrorInteraction().

Upstream PySide2 reference signatures (binding differences may apply):

release(self) -> None

Source: https://doc.qt.io/archives/qt-5.15/qsessionmanager.html#release

requestPhase2

requestPhase2() -> None

X.requestPhase2()

Supplemental documentation: Qt 5 reference:

void QSessionManager::requestPhase2()

Requests a second session management phase for the application. The application may then return immediately from the QGuiApplication::commitDataRequest() or QApplication::saveStateRequest() function, and they will be called again once most or all other applications have finished their session management.

The two phases are useful for applications such as the X11 window manager that need to store information about another application's windows and therefore have to wait until these applications have completed their respective session management tasks.

Note: If another application has requested a second phase it may get called before, simultaneously with, or after your application's second phase.

See also isPhase2().

Upstream PySide2 reference signatures (binding differences may apply):

requestPhase2(self) -> None

Source: https://doc.qt.io/archives/qt-5.15/qsessionmanager.html#requestPhase2

restartCommand

restartCommand() -> tuple

X.restartCommand() -> tuple

Supplemental documentation: Qt 5 reference:

QStringList QSessionManager::restartCommand() const

Returns the currently set restart command.

To iterate over the list, you can use the foreach pseudo-keyword:

const QStringList commands = mySession.restartCommand();
for (const QString &command : commands)
    do_something(command);

See also setRestartCommand() and restartHint().

Upstream PySide2 reference signatures (binding differences may apply):

restartCommand(self) -> typing.List[str]

Source: https://doc.qt.io/archives/qt-5.15/qsessionmanager.html#restartCommand

restartHint

restartHint() -> Any

X.restartHint()

Supplemental documentation: Qt 5 reference:

QSessionManager::RestartHint QSessionManager::restartHint() const

Returns the application's current restart hint. The default is RestartIfRunning.

See also setRestartHint().

Upstream PySide2 reference signatures (binding differences may apply):

restartHint(self) -> PySide2.QtGui.QSessionManager.RestartHint

Source: https://doc.qt.io/archives/qt-5.15/qsessionmanager.html#restartHint

sessionId

sessionId() -> str

X.sessionId() -> str

Supplemental documentation: Qt 5 reference:

QString QSessionManager::sessionId() const

Returns the identifier of the current session.

If the application has been restored from an earlier session, this identifier is the same as it was in the earlier session.

See also sessionKey() and QGuiApplication::sessionId().

Upstream PySide2 reference signatures (binding differences may apply):

sessionId(self) -> str

Source: https://doc.qt.io/archives/qt-5.15/qsessionmanager.html#sessionId

sessionKey

sessionKey() -> str

X.sessionKey() -> str

Supplemental documentation: Qt 5 reference:

QString QSessionManager::sessionKey() const

Returns the session key in the current session.

If the application has been restored from an earlier session, this key is the same as it was when the previous session ended.

The session key changes with every call of commitData() or saveState().

See also sessionId() and QGuiApplication::sessionKey().

Upstream PySide2 reference signatures (binding differences may apply):

sessionKey(self) -> str

Source: https://doc.qt.io/archives/qt-5.15/qsessionmanager.html#sessionKey

setDiscardCommand

setDiscardCommand(arg__1: Any) -> None

X.setDiscardCommand(arg__1)

Supplemental documentation: Qt 5 reference:

void QSessionManager::setDiscardCommand(const QStringList \&command)

Sets the discard command to the given command.

See also discardCommand() and setRestartCommand().

Upstream PySide2 reference signatures (binding differences may apply):

setDiscardCommand(self, arg__1: typing.Sequence[str]) -> None

Source: https://doc.qt.io/archives/qt-5.15/qsessionmanager.html#setDiscardCommand

setManagerProperty

setManagerProperty(name: str, value: Any) -> None

X.setManagerProperty(name, value)

Supplemental documentation: Qt 5 reference:

void QSessionManager::setManagerProperty(const QString \&name, const QStringList \&value)

Low-level write access to the application's identification and state record are kept in the session manager.

The property called name has its value set to the string list value.

void QSessionManager::setManagerProperty(const QString \&name, const QString \&value)

This is an overloaded function.

Low-level write access to the application's identification and state records are kept in the session manager.

The property called name has its value set to the string value.

Upstream PySide2 reference signatures (binding differences may apply):

setManagerProperty(self, name: str, value: str) -> None
setManagerProperty(self, name: str, value: typing.Sequence[str]) -> None

Source: https://doc.qt.io/archives/qt-5.15/qsessionmanager.html#setManagerProperty

setRestartCommand

setRestartCommand(arg__1: Any) -> None

X.setRestartCommand(arg__1)

Supplemental documentation: Qt 5 reference:

void QSessionManager::setRestartCommand(const QStringList \&command)

If the session manager is capable of restoring sessions it will execute command in order to restore the application. The command defaults to

appname -session id

The -session option is mandatory; otherwise QGuiApplication cannot tell whether it has been restored or what the current session identifier is. See QGuiApplication::isSessionRestored() and QGuiApplication::sessionId() for details.

If your application is very simple, it may be possible to store the entire application state in additional command line options. This is usually a very bad idea because command lines are often limited to a few hundred bytes. Instead, use QSettings, temporary files, or a database for this purpose. By marking the data with the unique sessionId(), you will be able to restore the application in a future session.

See also restartCommand(), setDiscardCommand(), and setRestartHint().

Upstream PySide2 reference signatures (binding differences may apply):

setRestartCommand(self, arg__1: typing.Sequence[str]) -> None

Source: https://doc.qt.io/archives/qt-5.15/qsessionmanager.html#setRestartCommand

setRestartHint

setRestartHint(arg__1: Any) -> None

X.setRestartHint(arg__1)

Supplemental documentation: Qt 5 reference:

void QSessionManager::setRestartHint(QSessionManager::RestartHint hint)

Sets the application's restart hint to hint. On application startup, the hint is set to RestartIfRunning.

Note: These flags are only hints, a session manager may or may not respect them.

We recommend setting the restart hint in QGuiApplication::saveStateRequest() because most session managers perform a checkpoint shortly after an application's startup.

See also restartHint().

Upstream PySide2 reference signatures (binding differences may apply):

setRestartHint(self, arg__1: PySide2.QtGui.QSessionManager.RestartHint) -> None

Source: https://doc.qt.io/archives/qt-5.15/qsessionmanager.html#setRestartHint