Bug report #11306
Qgis 2.4: Can't visualize a picture in a form obtained from Qt Designer
|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|
I have a problem with inserting a picture into a form in QGIS 2.4 with QT designer.
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
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 !!!