Maybe it's just the problem with the example, but main() in the first post is not calling newWindow()?
Here are a couple of examples. Two windows appear with self-explanatory titles:
// main.cpp
#include <QApplication>
#include <QMainWindow>
void newWindow()
{
window->setWindowTitle("Created in newWindow()");
window->setAttribute(Qt::WA_DeleteOnClose);
window->show();
}
{
window->setWindowTitle("Created in createWindow()");
window->setAttribute(Qt::WA_DeleteOnClose);
return window;
}
int main(int argc, char* argv[])
{
newWindow();
window->show();
return a.exec();
}
// main.cpp
#include <QApplication>
#include <QMainWindow>
void newWindow()
{
QMainWindow* window = new QMainWindow;
window->setWindowTitle("Created in newWindow()");
window->setAttribute(Qt::WA_DeleteOnClose);
window->show();
}
QMainWindow* createWindow()
{
QMainWindow* window = new QMainWindow;
window->setWindowTitle("Created in createWindow()");
window->setAttribute(Qt::WA_DeleteOnClose);
return window;
}
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
newWindow();
QMainWindow* window = createWindow();
window->show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks