Skip to content

Simple things using QML

Sathya Prasad edited this page May 18, 2016 · 3 revisions

Open URL or Link externally (launches in a browser on the device) using QML

Qt.openUrlExternally(link);

Here is a sample using this inside a text control where if the text contains any link it will get launched externally in a browser on the device:

Text {
        id: textControl

        width: parent.width
        wrapMode: Text.WrapAtWordBoundaryOrAnywhere
        elide: Text.ElideRight
        visible: text > ""
        font {
            pointSize: 13
        }
        textFormat: Text.RichText

        onLinkActivated: {
            Qt.openUrlExternally(link);
        }
    }

Here is opening a link using button:

   Button {
            width: 200
            height: width/5
            text: "Open PDF as Link"
            onClicked: {   
          Qt.openUrlExternally("https://www.arcgis.com/sharing/rest/content/items/4809581f1684444996ee4818dbcdb7c3/data");
            }
        }

Clone this wiki locally