If you create more than one window inside of main(), how do destroy all of them when the main window is closed by the user? So he does not have to close all windows manually?
Code example:
#ifndef CLOSETEST_H
#define CLOSETEST_H
#include <QtGui>
public:
};
#endif
#ifndef CLOSETEST_H
#define CLOSETEST_H
#include <QtGui>
class CloseTest : public QWidget {
public:
CloseTest(QWidget *parent = 0);
};
#endif
To copy to clipboard, switch view to plain text mode
#include "CloseTest.h"
CloseTest
::CloseTest(QWidget *parent
){
layout->addWidget(label);
setLayout(layout);
}
#include "CloseTest.h"
CloseTest::CloseTest(QWidget *parent)
{
QHBoxLayout *layout = new QHBoxLayout;
QLabel *label = new QLabel("This is a test");
layout->addWidget(label);
setLayout(layout);
}
To copy to clipboard, switch view to plain text mode
#include <QApplication>
#include "CloseTest.h"
int main(int argc, char *argv[])
{
QLabel main
("This is the main label");
main.resize(300,150);
main.show();
CloseTest ct;
ct.show();
return app.exec();
}
#include <QApplication>
#include "CloseTest.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel main("This is the main label");
main.resize(300,150);
main.show();
CloseTest ct;
ct.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks