0

My Symbian (Belle) main.qml has the standard:

window.pageStack.depth <= 1 ? Qt.quit() : window.pageStack.pop()

when the the back toolbar button is pressed which closes my app when pressed. I want to know what I should use to just minimize (or hide) my app when it is pressed like if I were to push menu button on the device? I searched for a solution but nothing seems to look right.

Edit:

Could you please just show how I should implement it it qml.

Gerharddc
  • 3,921
  • 8
  • 45
  • 83

3 Answers3

1

To minimize your main widow in a right way in Symbian you should do steps below. Step 1: Create wrapper for QDeclarativeView

#include <QtCore/QPointer>
#include <QtDeclarative/QDeclarativeView>
#ifdef Q_OS_SYMBIAN
#   include <e32base.h>
#   include <w32std.h>
#   include <apgwgnam.h>
#   include <coedef.h>
#   include <coecntrl.h>
#   include <coemain.h> 
#endif

class View : public QObject {
    Q_OBJECT
    // ...
public:
    // ...
    Q_INVOKABLE void showMinimized() {
#ifdef Q_OS_SYMBIAN
        RWindowGroup* wg = &CCoeEnv::Static()->RootWin();
        wg->SetOrdinalPosition(-1);
#else
        view_->showMinimized();
#endif
    }
    // ...
private:
    QPointer<QDeclarativeView> view_;
};

Then use this View as QML context property:

QScopedPointer<QDeclarativeView> view(new QDeclarativeView());
view->rootContext()->setContextProperty("applicationWindow", new View(view.data(), view.data()));

Then your QML code will looks like that:

tools: ToolBarLayout {
    ToolButton {
        flat: true
        iconSource: "qrc:/images/tbar-back.svg"
        onClicked: applicationWindow.showMinimized()
}
Pavel Osipov
  • 2,067
  • 1
  • 19
  • 27
0

Use mainwindow.setWindowState(Qt::WindowMinimized) for minimizing your App.

ScarCode
  • 3,074
  • 3
  • 19
  • 32
0

I ended up using the "lower()" function of the QMLViewer

QObject::connect(rootObject, SIGNAL(hide()), &viewer, SLOT(lower()));

then simply connecting it to a lower() function in qml and then calling it when the back button is pressed. ShowMinimised lets the window disappear.

Gerharddc
  • 3,921
  • 8
  • 45
  • 83