I tested this with a derived class, but it is the same with the QDialog base class:
when i do
QDialog dialog(); dialog.exec();
the compiler complains
J:\...\mainwindow.cpp:-1: In member function 'void MainWindow::on_viewButton_pressed()': J:\...\mainwindow.cpp:72: Fehler:request for member 'exec' in 'dialog', which is of non-class type 'QDialog()'
This has something to do with the constructor used, because when I do
QDialog dialog(0); dialog.exec();
The code compiles without errors. This also works:
QDialog *dial = new QDialog(); dial->exec();
So. Is this because of an explicit constructor?
The documentation says that it is defined as
QDialog::QDialog ( QWidget * parent = 0, Qt::WindowFlags f = 0 )
So the first two examples should not match? And why does the compiler complain about the second line, and not about the constructor.
Thanks for the enlightenment, we welcome further readings on the topic.
source share