Bug report #11306
Qgis 2.4: Can't visualize a picture in a form obtained from Qt Designer
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | Nathan Woodrow | ||
Category: | - | ||
Affected QGIS version: | 2.4.0 | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 19602 |
Description
Hello,
I have a problem with inserting a picture into a form in QGIS 2.4 with QT designer. Something that worked in QGIS 2.2 no longer work in 2.4
I explain.
For example, I have a point vector layer « trafic sign ». I want when I click on a trafic sign on the map, a consultation form appears with interesting attributs to me. Including the picture of this trafic sign.
So, to create this personalized form with a picture changing according to the selected entity, you must have :
- a layer with a field « PICTURE » type text with the path to that picture. Be careful, path with / not \\ !!
- then, go to « Layer properties » of this layer, « Fields », and for this field « PICTURE », in column « edit widget » change « line edit » to « photo ».
From there, two options are available to us.
- Make a form « design with drag and drop ». This is findable in « Layer Properties », « Fields », at the top in « Attribute editor layout ». A new section appears on the right. Then, create « tabs » with the + and just drag the interesting fields in this section.
- Or use a form created with Qt designer. In Qt, the area for the picture is a « QWebview » with ObjectName « PICTURE » like the field in QGIS. In Qgis, this time, you have to choose « Provide ui-file » in « Attribute editor layout ». Click the ellipsis button and choose the file you created in Qt.
Now, when you are in edit mode and capture a new point, you should have one or either of your custom dialog form instead of the generic one. You can also have this dialog form when you click on one of your points using the identify tool : http://docs.qgis.org/2.2/en/docs/training_manual/create_vector_data/forms.html?highlight=form
Except there is a problem with the picture. Both methods worked under 2.2, and now, only the first running under 2.4 (design with drag and drop).
It's unfortunate because .ui files created in QT really helps make ergonomics and pleasant forms, adapted to what you want exactly. Items can be placed wherever you want, they can be resized, you can insert text, logos, you can custom field labels... And also realize many scripts with Python to do specials actions with these items. In my job, I work a lot with that.
I put some screenshots.
Sorry for my terrible English (i'm French).... And thank you in advance for the solution !!!
Kathy
Associated revisions
Allow QWebView for photo widget
Fix #11306
History
#1 Updated by CANO Kathy about 10 years ago
- Assignee set to Nathan Woodrow
#2 Updated by Matthias Kuhn about 10 years ago
- Status changed from Open to Feedback
Which widget type did you use to show the picture in the .ui-file?
Would you be able to share the .ui file?
#3 Updated by CANO Kathy about 10 years ago
- File form_vanne.ui added
I use a Qwebview and it worked well in 2.2
I share the .ui file
#4 Updated by Matthias Kuhn about 10 years ago
- Status changed from Feedback to Open
As a workaround, you can use a QLabel instead of a QWebView (This approach should be backwards compatible with 2.2)
But I'll have a look at the webview solution.
#5 Updated by Matthias Kuhn about 10 years ago
- Status changed from Open to Closed
Fixed in changeset 17ca96fd26720c964e42123ce1196b01355424d9.