Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

PictureViewer

A modal, full-screen picture viewer component. More...

Import Statement: import Felgo 3.0

Properties

Signals

Methods

  • bool close()
  • Item show(Window window, url image, bool scaleImage)

Detailed Description

PictureViewer is a global object with convenience methods for showing a full-screen AppImage item.

The picture viewer will show a full-screen black background and the image on top, using preserve-aspect scaling. Clicking anywhere on the screen will close the picture viewer again. If available, the picture viewer also closes with the platform's back button (e.g. on Android).

Use show() to show an image specifying a source url, like:

 App {
 id: app

   AppButton {
     text: "Show image"
     onClicked: {
       // Open PictureViewer component
       PictureViewer.show(app, "image.png")
     }
   }
 }

Use close() to close a currently visible picture viewer from code.

Use currentViewer to obtain the currently visible picture viewer Item.

Property Documentation

currentViewer : Item

The currently visible picture viewer item, if any.


[read-only] isOpen : bool

Whether the PictureViewer is currently opened.

This property was introduced in Felgo 2.7.0.


Signal Documentation

closed()

Is fired when the pictureViewer is closed. As PictureViewer is a singleton object, a Connections item is needed to access the signal:

 Connections {
   target: PictureViewer
   onClosed: { console.log("viewer closed") }
 }

This signal was introduced in Felgo 2.7.0.


opened(var = image)

Is fired when the pictureViewer is opened. The image parameter holds the url of the shown image. As PictureViewer is a singleton object, a Connections item is needed to access the signal:

 Connections {
   target: PictureViewer
   onOpened: { console.log("viewer opened") }
 }

This signal was introduced in Felgo 2.7.0.


Method Documentation

bool close()

Closes the currently visible picture viewer. Returns true if a dialog was currently visible.


Item show(Window window, url image, bool scaleImage)

Shows a picture viewer with the specified image source url.

The window parameter should be a reference to the root QML Window, or in many cases the App object. If it is not specified, the picture viewer will not work.

scaleImage is an optional parameter and defaults to true. When set to false, the image is not scaled up to fit the screen if it is smaller. Images that are too big are always scaled down to fit the screen.

Returns the created picture viewer item if it has been opened, and no InputDialog was already opened before the call, otherwise returns the previously visible picture viewer Item.

Note: Only one PictureViewer can be shown at a time. If a dialog is currently visible, nothing happens and this dialog is returned.