Can't use SingleApplication
-
I try https://github.com/itay-grudev/SingleApplication
I set macro set(QAPPLICATION_CLASS QGuiApplication)
but still error "QWidget: Cannot create a QWidget without QApplication"
is in qwidget.cppvoid QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) { Q_Q(QWidget); Q_ASSERT_X(q != parentWidget, Q_FUNC_INFO, "Cannot parent a QWidget to itself"); if (Q_UNLIKELY(!qobject_cast<QApplication *>(QCoreApplication::instance()))) qFatal("QWidget: Cannot create a QWidget without QApplication");
-
I try https://github.com/itay-grudev/SingleApplication
I set macro set(QAPPLICATION_CLASS QGuiApplication)
but still error "QWidget: Cannot create a QWidget without QApplication"
is in qwidget.cppvoid QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) { Q_Q(QWidget); Q_ASSERT_X(q != parentWidget, Q_FUNC_INFO, "Cannot parent a QWidget to itself"); if (Q_UNLIKELY(!qobject_cast<QApplication *>(QCoreApplication::instance()))) qFatal("QWidget: Cannot create a QWidget without QApplication");
@AndrzejB
The example, and the error message, is forQApplication
. You have put inset(QAPPLICATION_CLASS QGuiApplication)
. You needQApplication
for widget applications. You can see that, and the consequent error message if you do not, in the code you pasted.