KXMLGUI Session Macros and Functions


#define RESTORE(type)


template<typename T >
void kRestoreMainWindows ()
template<typename T0 , typename T1 , typename... Tn>
void kRestoreMainWindows ()

Detailed Description

Macro Definition Documentation



Returns the maximal number of arguments that are actually supported by kRestoreMainWindows().

Definition at line 791 of file kmainwindow.h.


#define RESTORE (   type)
{ \
int n = 1; \
(new type)->restore(n); \
n++; \
} \

Restores the last session.

since 5.0, use kRestoreMainWindows() instead

Definition at line 776 of file kmainwindow.h.

Function Documentation

◆ kRestoreMainWindows() [1/2]

template<typename T >
void kRestoreMainWindows ( )

Restores the last session.

(To be used in your main function).

These functions work also if you have more than one kind of top-level widget (each derived from KMainWindow, of course).

Imagine you have three kinds of top-level widgets: the classes childMW1, childMW2 and childMW3. Then you can just do:

int main(int argc, char *argv[])
// [...]
if (qApp->isSessionRestored())
kRestoreMainWindows<childMW1, childMW2, childMW3>();
else {
// create default application as usual
// [...]

kRestoreMainWindows<>() will create (on the heap) as many instances of your main windows as have existed in the last session and call KMainWindow::restore() with the correct arguments. Note that also QWidget::show() is called implicitly.

Currently, these functions are provided for up to three template arguments. If you need more, tell us. To help you in deciding whether or not you can use kRestoreMainWindows, a define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS is provided.

Prefer this function over directly calling KMainWindow::restore().
Template Parameters
TTop-level widget class
See also

Definition at line 833 of file kmainwindow.h.

◆ kRestoreMainWindows() [2/2]

template<typename T0 , typename T1 , typename... Tn>
void kRestoreMainWindows ( )

Restores the last session.

This is an overloaded function.

Use this with multiple different top-level widget classes.

Template Parameters
T0One top-level widget class
T1Explicit other top-level widget class for disambiguation from base template
TnParameter pack to take 0..n further KMainWindows
See also

Definition at line 855 of file kmainwindow.h.

Type type(const QSqlDatabase &db)
static bool canBeRestored(int numberOfInstances)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 04:04:23 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.