• May 17, 2024, 02:11:13 pm

Author Topic: [TUT] How to launch a website in default browser on App start with QML  (Read 856 times)

0 Members and 1 Guest are viewing this topic.

Offline Allstar12345

  • Allstar Software Founder
  • Administrator
  • Forum Genius
  • ******
  • Posts: 5,235
  • Reputation: 812
    • Allstar Software
  • Current Phone: : OnePlus 8 Pro, Xperia 10, Nexus 6p, Jolla Phone, Nokia N8, Nokia 808 PureView, BlackBerry Z30
This one really really basic, I used a Timer because it didn't want to close immediately.

Start with the imports:
Code: [Select]
import QtQuick 1.0
import com.nokia.symbian 1.1

Then I defined a PageStackWindow, you can use this, Page, or Window, it doesn't really matter.

Code: [Select]
PageStackWindow {
    showToolBar: false
    showStatusBar: false
}


Then I use a QML Timer to trigger the Exit of the Application, it is set to 100 milliseconds here:
Code: [Select]
Timer {
        id: startexit
             interval: 100; running: false; repeat: false
             onTriggered: {
                 Qt.quit();

             }
         }


After that is the Component.onCompleted, this is what triggers the Web browser to be launched and the timer to be started:

Code: [Select]
Component.onCompleted: {
        Qt.openUrlExternally ('http://symbian-developers.net')
        startexit.start();
    }


All together it should look like this:


Code: [Select]
import QtQuick 1.0
import com.nokia.symbian 1.1
PageStackWindow {
    showToolBar: false
    showStatusBar: false
    Timer {
        id: startexit
             interval: 100; running: false; repeat: false
             onTriggered: {
                 Qt.quit();

             }
         }
    Component.onCompleted: {
        Qt.openUrlExternally ('http://sdf.allstarsoftware.co.uk')
        startexit.start();
    }
}