No, you don't need an "intermediary" widget, you pass 0 (NULL), the only thing is that you are responsible to delete the widgets that don't get a parent (or get that NULL) so that you trigger the proper deletion of it's children widgets, this can be done either by allocating the "mainWindow" on the stack in the main function or call delete if you allocated it on stack.
LE: Full example code:
#include <QApplication>
#include <QMainWindow>
#include <QPushButton>
{
Q_OBJECT
public:
};
{
}
int main(int argc, char *argv[])
{
appWindow w;
QObject::connect(w.
quit,
SIGNAL(clicked
()),
&app,
SLOT(quit
()));
w.show();
return app.exec();
}
#include "main.moc"
#include <QApplication>
#include <QMainWindow>
#include <QPushButton>
class appWindow : public QMainWindow
{
Q_OBJECT
public:
appWindow(QWidget* parent = 0);
QPushButton *quit;
};
appWindow::appWindow(QWidget* parent) : QMainWindow(parent)
{
quit = new QPushButton("quit", this);
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
appWindow w;
QObject::connect(w.quit, SIGNAL(clicked()), &app, SLOT(quit()));
w.show();
return app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks