0

Newbie to QT QML and sorry if its just very simple ask.

I have simple piece of code that demonstrate WebEngine Qt Quick example.

/* runtime.qml*/
import QtQuick 2.1
import QtQuick.Controls 1.1
import QtWebEngine 1.1

ApplicationWindow {
    width: 1080
    height: 1488
    visible: true
    flags: Qt.WindowFullScreen | Qt.FramelessWindowHint
    WebEngineView {
            url: "http://www.qt.io"
            anchors.fill: parent
    }
}

It simply would display a web page and is invoked by following script:

#!/bin/sh
exec /usr/bin/qt5/qmlscene "$1" runtime.qml

This script is triggered when widget placed on some "other window" is clicked

Now, I want that surface created by runtime.qml to be destroyed when someone goes back to "other window" from where script is triggered.

Milan
  • 1,447
  • 5
  • 19
  • 27
  • You have to clarify what are these other windows. `Window` has `close()` method so you can close it on losing focus or whatever. – folibis Dec 08 '18 at 18:40

2 Answers2

1

Qt.quit() will do the trick :

MouseArea{
                  anchors.fill: parent
                  onClicked: {
                         Qt.quit()
                  }
         }

your question is not clear enough you may need a Timer too, are you using a Loader for runtime.qml or loading it?
or instead of using windows you may want to look at Popup which can be opened or closed.

Mahdi Khalili
  • 1,025
  • 15
  • 32
0

You can use a close button to close the window, like this:

    Image {
        id: quitButton
        width: 50
        height: 50
        fillMode: Image.PreserveAspectFit
        source: mouseAreaQuitButton.containsMouse ?
                    "../images/titleBar/quit_hover.png" :
                    "../images/titleBar/quit.png"
        MouseArea {
            id: mouseAreaQuitButton
            anchors.fill: parent
            hoverEnabled: true
            onClicked: Qt.quit()
        }
    }
Adriano Campos
  • 1,121
  • 7
  • 14