'Open a pdf file from local directory on button Click in QML
Image {
id: user_guide_over
source: "qrc:/images/loginPage/user_guide_over.png"
x: ((parent.width/rootItemWidth)*1004)
y: ((parent.height/rootItemHeight)*646)
opacity: 1
visible: false
width: ((bgRect.width/rootItemWidth)*sourceSize.width)
height: ((bg.height/rootItemHeight)*sourceSize.height) }
The above is a image button that I have created. Now I have my PDF file inside my images folder and what to open it in read mode. I tried the following approach. When the above button is clicked, I get a pop up "You'll need a new app to open this qrc link". What is the Alternative approach to this, to open the pdf file in default pdf reader in any system.
MouseArea {
anchors.fill: user_guide
onClicked: {
Qt.openUrlExternally("qrc:images/ug.pdf");
}
Solution 1:[1]
Looks like you're missing the / in openUrlExternally link.
It's worth using js function or C++ to verify the file actually exists so this works as you intend
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Swerve |
