Reply
Thread Tools
Markkyboy's Avatar
Posts: 433 | Thanked: 727 times | Joined on Oct 2012 @ Costa Blanca, Espaņa
#1
How to call/open another page/application from within a QML file?

Using 'Qt.openUrlExternally works in some cases, like sending an email by using 'mailto:' but the same cannot be said for opening files, like say a 'jpg' or a page from an application.

This works, as an example for 'mailto';

Code:
    MouseArea {

        property string myText: "mailto: fred@bloggs.com"

        id: mouseArea
        anchors.fill: clockText
        onClicked: {
            Qt.openUrlExternally(myText)
        }

I am unable to open any .desktop file using Qt.openUrlExternally or pageStack.push methods - yet from shell, I can open jolla-clock a few ways, but not from within another file.

What am I missing here?

As an example, this works from within a QML file; (it opens the settings dialog for the given application)

Code:
    MouseArea {
        id: mouseArea
        anchors.fill: clockText
        onClicked: {
            pageStack.push(Qt.resolvedUrl("/usr/share/openrepos-clock-settings/clocksettings.qml"))
        }
But try doing this to open a .desktop file or even a file type like a jpg, despite changing pageStack.push for Qt.openUrl Externally(""), but it still doesn't function.

Any ideas of pointers for basically being able to open a page of one application from another.

I have trawled many pages and found conflicting/old/dead end information, barely any of which relates to SFOS.
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..

Last edited by Markkyboy; 2016-09-27 at 16:46. Reason: Qt.resolvedUrl or Qt.openUrlExternally
 

The Following 2 Users Say Thank You to Markkyboy For This Useful Post:
Feathers McGraw's Avatar
Posts: 654 | Thanked: 2,368 times | Joined on Jul 2014 @ UK
#2
Bump!

I'd like to know the answer to this too, out of interest.

Does it work for pages that have no C++ objects? If you place a really simple qml file in your home directory, can you push it?
 
Markkyboy's Avatar
Posts: 433 | Thanked: 727 times | Joined on Oct 2012 @ Costa Blanca, Espaņa
#3
I don't understand your questions. I wouldn't recognise C++ from a kick in the balls or how to 'push' a file from 'home'..?, can you explain more in layman terms please...?
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..
 
coderus's Avatar
Posts: 6,436 | Thanked: 12,699 times | Joined on Nov 2011 @ Ängelholm, Sweden
#4
Qt.openUrlExternally("/usr/share/applications/jolla-clock.desktop")

works for me
__________________
Telegram | Openrepos | GitHub | Revolut donations
 
Markkyboy's Avatar
Posts: 433 | Thanked: 727 times | Joined on Oct 2012 @ Costa Blanca, Espaņa
#5
coderus, where do you place the code to test it?
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..
 
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#6
did you tried also this way ?
Code:
Qt.resolvedUrl("file:///path/to/your.qml")
 
Markkyboy's Avatar
Posts: 433 | Thanked: 727 times | Joined on Oct 2012 @ Costa Blanca, Espaņa
#7
Hi Schturman, thanks for replying, but no, that doesn't seem to work either. I don't understand, but I'm really pleased it works for coderus.
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..
 
Feathers McGraw's Avatar
Posts: 654 | Thanked: 2,368 times | Joined on Jul 2014 @ UK
#8
Originally Posted by Markkyboy View Post
I wouldn't recognise C++ from a kick in the balls
Doesn't your application have a main function written in C++?

or how to 'push' a file from 'home'..?, can you explain more in layman terms please...?
What I mean is that lots of applications have C++ parts and QML parts, where QML is used (mostly) for graphical stuff, and C++ is used for the backend data work.

Some of those applications have data structures and classes defined in C++ that are included in the QML file so that the objects can be initialised and used from QML.

Sometimes the objects the application needs for the backend are created when the first qml page is loaded, like in hammerhead torch, which initialises the LEDControl object in harbour-hammerhead-torch.qml, and then uses it in other pages like MainPage.qml by referring to it by its id ("led").

I don't think MainPage.qml from hammerhead torch would work if you just loaded it directly, because "led" wouldn't refer to anything. I don't know if that means it wouldn't load at all, or if the page would load with errors.

When I said push a page I was talking about the page stack ("pageStack.push"), and home was referring to /home/nemo (a convenient place to place a test qml file).
 

The Following User Says Thank You to Feathers McGraw For This Useful Post:
Markkyboy's Avatar
Posts: 433 | Thanked: 727 times | Joined on Oct 2012 @ Costa Blanca, Espaņa
#9
Okay, thanks for clarification (I'm still learning!).

I'm not actually making an application, i'm simply editing existing files and seeing what happens, basically fishing for ideas to customise my device.

In this case, I wanted to go directly to the alarm dialog page by tapping on the time on lockscreen. This means, I have directly edited Clock.qml, found in '/usr/share/lipstick-jolla-home-qt5/lockscreen/*'.
To make this happen, I used MouseArea to make the time clickable and it opened the application settings for Openrepos-clock-settings (a .qml file) - success!, but when it comes to opening say, a file or desktop file, nothing happens.
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..
 
coderus's Avatar
Posts: 6,436 | Thanked: 12,699 times | Joined on Nov 2011 @ Ängelholm, Sweden
#10
Much more info now.
Inside lipstick you cant use openUrlExternally

you should create
Code:
LauncherItem {
    id: jollaClock
    filePath: "/usr/share/applications/jolla-clock.desktop"
}
and call jollaClock.launchApplication()
__________________
Telegram | Openrepos | GitHub | Revolut donations
 

The Following 2 Users Say Thank You to coderus For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 12:16.