2

Basically I have (The Game class just wraps QGuiApplication):

int Game::run()
{
    QQuickView * mMainView = new QQuickView;
    mMainView->setResizeMode(QQuickView::SizeRootObjectToView);
    mMainView->setSource(QUrl("qrc:///main.qml"));

    mMainView->show();

    return mApp.exec();
}

Main:

int main(int argc, char ** argv)
{
    Game game(argc, argv);
    return game.run();
}

And the QML:

import QtQuick 2.2

Rectangle {
    width: 256
    height: 256
}

When I compile and run, it crashes like this:

#0  strlen () at ../sysdeps/x86_64/strlen.S:106
#1  0x00007ffff6858221 in QCoreApplication::arguments() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#2  0x00007fffed9f9ad3 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so
#3  0x00007fffed9f9fbd in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so
#4  0x00007fffeda06af2 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so
#5  0x00007fffed9f9731 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so
#6  0x00007ffff6fb4efe in QWindow::create() () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#7  0x00007ffff6fb57b0 in QWindow::setVisible(bool) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#8  0x000000000041f04c in Game::run (this=this@entry=0x7fffffffd9b0) at /home/xxxxxx/src/game.cpp:71
#9  0x000000000041e44a in main (argc=1, argv=0x7fffffffdc78) at /home/xxxxxx/main.cpp:11

WTF? I cannot run even a simplest possible QQuick application..

1 Answer 1

2

The problem was that the signature of QGuiApplication's constructor is actually QGuiApplication(int & argc, char ** argv).

Notice that reference & with argc ! :)

I had passed argc by value so the app crashed when argc variable went out of scope.

1
  • thank you so much, I was searching for this for 6 hours!
    – SimonH
    Jan 14, 2016 at 15:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .