QWIDGET: CANNOT CREATE A QWIDGET WITHOUT QAPPLICATION - Message Box
-
wrote on 28 Jul 2016, 13:43 last edited by
Hi,
I used the Qmessage Box in the project created Qt Quick C++ template.
When I try to show an message box, I encounter the following error:QWIDGET: CANNOT CREATE A QWIDGET WITHOUT QAPPLICATION
Code:
void QtCPPSearchVOne::funsearchMap()
{
QString obj;
obj = QString::QString("Event Fired");QMessageBox msgbox;
msgbox.setText(obj );
msgbox.exec();
}Thanks in advance.
Mathan
-
Hi,
Go to your
main.cpp
You'll see there that aQGuiApplication
is created. Replace it by QApplication.As to why: there's no need for widget support when writing a Qt Quick application unless you make use of classes like QMessageBox.
-
Hi,
Go to your
main.cpp
You'll see there that aQGuiApplication
is created. Replace it by QApplication.As to why: there's no need for widget support when writing a Qt Quick application unless you make use of classes like QMessageBox.
wrote on 13 May 2021, 01:26 last edited by@SGaist said in QWIDGET: CANNOT CREATE A QWIDGET WITHOUT QAPPLICATION - Message Box:
writing
Thank you so much! I had a problem with opencv::imshow. And this solution works well.