File indexing completed on 2024-05-05 05:00:14

0001 /* This file is part of the KDE project
0002     SPDX-FileCopyrightText: 2006 David Faure <faure@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "centralwidget.h"
0008 
0009 #include <QApplication>
0010 #include <QLabel>
0011 #include <QTimer>
0012 
0013 SCWMainWindow::SCWMainWindow(QWidget *parent)
0014     : QMainWindow(parent)
0015 {
0016     QLabel *widget1 = new QLabel(QStringLiteral("widget1"));
0017     setCentralWidget(widget1);
0018     QTimer::singleShot(10, this, SLOT(slotSwitchCentralWidget()));
0019 }
0020 
0021 void SCWMainWindow::slotSwitchCentralWidget()
0022 {
0023     QLabel *widget2 = new QLabel(QStringLiteral("widget2"));
0024     delete centralWidget(); // ## workaround for the crash
0025     setCentralWidget(widget2);
0026 }
0027 
0028 int main(int argc, char **argv)
0029 {
0030     QApplication app(argc, argv);
0031 
0032     SCWMainWindow *mw = new SCWMainWindow;
0033     mw->show();
0034 
0035     return app.exec();
0036 }
0037