TransWikia.com

QGIS 3.6 picture in ui form (Qt5 Designer)

Geographic Information Systems Asked by SYG on April 4, 2021

I’m facing trouble with display a picture in a ui form based on a field (path).
With the autogenerate form it works but when I try with a personalized form I cannot see the picture.
I tried with a Qlabel and QWebView in Qt Designer and in QGIS layer property I put the field as Attachment but without success.

I know that I can make a little python script to achieve this but I would like to store the ui in a db.

Does anyone have an idea ?

2 Answers

you can use tips tool in qgis and write with html code for insert any file and even open file out of qgis

Answered by GIS_Esri on April 4, 2021

It seems possible by tricking QGIS and Qt Creator.

This is how I proceeded.

In QtCreator, you create a new QTextBrowser widget. As usual, you give it the name of the QGIS source field. You need to right click on the new widget and select "Promote In…" and enable both options "QtWebView/QtWebKit" and "QgsExternalResourceWidget" if they are not.

enter image description here

In QGIS now, you select your custom form. The source field has to be set as a Text source. You have to enable HTML rendering as well.

enter image description here

The data has to be input as HTML inside the field. So you can create for example a field in which you will store the path of your picture and then create a calculation field rendering HTML as follow:

'<img src="' || "Photo" || '">'

enter image description here

That's all what you have to do. That will let you create more beautiful forms than the ones in QGIS. It's even more simple than before.

Answered by M-Rick on April 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP