We have moved to a new Sailfish OS Forum. Please start new discussions there.
1

[solved] How to quit custom app programmatically (Qml)?

asked 2014-02-28 16:30:46 +0300

Ragnar Kurm gravatar image

updated 2014-03-02 10:33:55 +0300

Hello,

Developing an app and having trouble quitting app. Not able to spot it from docs. I'm trying to do it like this:

    BackgroundItem {
        onClicked: Qt.quit()
        Label {
            text: "Quit"
        }
    }

But get following result:

[W] QQmlEnginePrivate::sendQuit:1687 - Signal QQmlEngine::quit() emitted, but no receivers connected to handle it.

edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted
4

answered 2014-02-28 18:22:08 +0300

fasza2mobile gravatar image

updated 2014-02-28 18:25:44 +0300

check the connect part in main.cpp:

http://developer.nokia.com/community/wiki/CS001626_-_Closing_a_Qt_Quick_application_from_QML

But I wouldn't put a Quit button when most of my users would expect the os default swipe action, so unless you are writing a game or for any other reason you must disable swipe don't put a quit button.

edit flag offensive delete publish link more

Comments

Thank you about the link and the clarification about good app design (and take it into account during release). Though I have seen the link, it raises more questions than answers for me. Why is Quit is so hard/complex to implement. My main function has just one line: return SailfishApp::main(argc, argv); Cannot see where to insert proper QObject::connect() which should do the trick.

Ragnar Kurm ( 2014-03-01 00:26:37 +0300 )edit
1

Well it is difficult if you don't know C++, why it is required to manually connect them I don't know. If you change your 1 liner in your main.cpp to this:

QGuiApplication* app = SailfishApp::application(argc, argv); QQuickView* view = SailfishApp::createView(); view->setSource(SailfishApp::pathTo("qml/main.qml")); view->show();

QObject::connect((QObject*)view->engine(), SIGNAL(quit()), app, SLOT(quit()));

return app->exec();

fasza2mobile ( 2014-03-01 16:15:35 +0300 )edit

Sorry text renders strangely even with code tags, just put new line after each ';'

fasza2mobile ( 2014-03-01 16:17:04 +0300 )edit

Thank you for showing step forward. I have already tried many variations of this code what I have found. When I try to run the code I get this:

[W] unknown:138 - file:///usr/lib/qt5/qml/Sailfish/Silica/Page.qml:138: ReferenceError: __silica_applicationwindow_instance is not defined

Caused by this:

view->setSource()

As a result I get WSOD.

Ragnar Kurm ( 2014-03-02 00:57:42 +0300 )edit
2

What argument did you give to "view->setSource()" ? I belive in your case it should be: SailfishApp::pathTo("qml/[insertYourProjectnameHere].qml")

that file contains ApplicationWindow {}

I think you've put your first page there.

fasza2mobile ( 2014-03-02 02:37:22 +0300 )edit
Login/Signup to Answer

Question tools

Follow
2 followers

Stats

Asked: 2014-02-28 16:30:46 +0300

Seen: 9,847 times

Last updated: Mar 02 '14