-
-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QWidget: Cannot create a QWidget without QApplication #165
Comments
Likely the same solution to #164 will also apply here.
…On Sat, 13 Aug 2022 at 19:31, Andrzej Borucki ***@***.***> wrote:
int main(int argc, char **argv)
{
SingleApplication app(argc, argv);
if( app.isSecondary() ) {
QStringList arguments = app.arguments();
app.sendMessage( arguments.join(' ').toUtf8() );
app.exit( 0 );
}
MainWindow mainWindow; //<--------------------------------HERE ERROR
mainWindow.resize(800, 600);
mainWindow.show();
return app.exec();
}
Error "QWidget: Cannot create a QWidget without QApplication" is on
creation MainWindow
I use after
https://stackoverflow.com/questions/17937618/how-to-use-qtsingleapplication,
but not QtSingleApplication but just SingleApplication
—
Reply to this email directly, view it on GitHub
<#165>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQGP55WU5G54E7BR6H5ZRLVY7SYFANCNFSM56OQVWIQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Kind Regards,
Itay Grudev
@: ***@***.***
in: https://www.linkedin.com/in/itaygrudev
W: https://itay.grudev.com
|
#164 macro helps. void 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"); But Calculator example works fine => maybe I have other invisible error. |
I just checked to be sure. QWidgets require QApplication instead of
QGuiApplication, so that is what you need to specify in your macro. If I
remember correctly, primaryScreen() is available in QApplication. That call
to primary screen should be changed to QApplication instead the Gui
alternative. Make sure you're consistent in your QApplication class usage
and see if that solves your problem. I have an app with exactly the same
setup and it works ok. There is no bug here.
…On Sun, 14 Aug 2022 at 08:19, Andrzej Borucki ***@***.***> wrote:
#164 <#164> macro
helps.
#165 <#165> in my
Qt version 5.15.2 (or 5.15.3 in my Mint21 installed) still is error:
"QWidget: Cannot create a QWidget without QApplication"
In Qt sources in qwidget.cpp:
void 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");
—
Reply to this email directly, view it on GitHub
<#165 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQGP563CS4IX3WIQKFYAGLVZB6WRANCNFSM56OQVWIQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
Kind Regards,
Itay Grudev
@: ***@***.***
in: https://www.linkedin.com/in/itaygrudev
W: https://itay.grudev.com
|
You need to set
I got this error because I defined it in main.cpp, which didn't set it in singleapplication.cpp. So even though The solution to this is to define it in the .pro file instead, which defines it for the whole project. |
Error "QWidget: Cannot create a QWidget without QApplication" is on creation MainWindow
I use after https://stackoverflow.com/questions/17937618/how-to-use-qtsingleapplication, but not QtSingleApplication but just SingleApplication
The text was updated successfully, but these errors were encountered: