3

In QGS (3.28.4 LTR), I'm trying to add a QML button to a form that will open the attached photo when pressed, but have encountered the problem that the button appears when the attachment field happens to be empty (a result of some kind of error, such as maybe forgetting to hit the green checkmark to accept the photo after taking it):

enter image description here

But not when there is a photo (the normal and desired case):

enter image description here

Here is the current code for the button (no onclick code yet, & the show label checkbox will get unchecked when this first problem is solved)

enter image description here

Annoyingly, the button appears properly in QField, where I ultimately want it not to appear, because the QField photo widget opens the photos on a click in the way I want, while QGIS doesn't seem to have that facility (you can sort of see why I want it from the photo; the bluish stuff near the bottom is the Australian 'blue devil' (Eryngium ovinum), completely different from the North American 'blue devil', and they are kind of hard to see, so you sometimes want a maximally big picture).

A further remark is that experimenting with different positions for the button in the list, such as above 'date', makes no difference. Could this be a limitation/bug in the QGIS attribute table form view?

7
  • 1
    Presumably you mean 3.28.4 not 2.28.4? Commented Mar 12, 2023 at 10:33
  • Yes. Goof corrected Commented Mar 12, 2023 at 10:42
  • 1
    In the screenshot with the photo preview, it looks like the button is not quite in the screen (it will appear below the "Button" label at the bottom). What happens if you make the photo preview a bit smaller? For the button text, you could perhaps use a case statement to alter the text to "no image available" if the photo file path field is empty
    – Matt
    Commented Mar 12, 2023 at 11:43
  • Moving the button higher up so that there are things under it (which do appear) does not help; the button still does not appear. Commented Mar 12, 2023 at 20:50
  • I faced a very similar issue recently, which I have yet to resolve. It seems that the button widget does not force the attribute form window to expand vertically (either physically, or by adding a scroll bar). You can see this if you make the photo smaller (I'm not suggesting this is a fix as it is not desirable). for me, the photo slides behind the widgets below it when the attribute table is scrolled, I had to put most of the attributes in a collapsible group box so I could view my photo (also not ideal). I had been intending to post a question but I think this is the same issue.
    – Matt
    Commented Mar 13, 2023 at 8:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.