1

I have created a dialog for QGIS in Qt-Designer to add and change attributes in a shapefile.(see picture) It's only a form, not a plugin. Everything works as it should be but there´s one attribute where the user has to press a button, select a file and the path should be written as a value into this attribute and shown in the lineEdit on the dialog next to the button.(similiar to Qt: add a file selection field on the form (QLineEdit and "browse" button) and PyQt4 File select widget)

From what i read i have to write a few lines python to make it work, because there´s no widget in Qt-Designer for that. But i didn't get how the whole code for this function is and where i have to write and save the code...

Unfortunatly I´m not a programmer, so it would be really nice if you can give me a small step-by-step version...

Astrid
  • 11
  • 2
  • What do you mean by _It's only a form, not a plugin_? I just skimmed over the documentation and could find lots of information about plugins, but none about forms. – pschill Oct 12 '17 at 12:43
  • As far as i read and see plugins will be created with the Qt-Creator and not the Qt-Designer. It seems, that in the Qt-Creator you have a project with different files. And one file is used fot the Code. But i don´t know where to write the Code in Qt-Designer, where you can only design the dialog (form). – Astrid Oct 12 '17 at 13:07
  • @pschill the Code related to the Dialog has to be stored somewhere else. In QGIS you can choose a python init function from an extern file or you can write it in the Fields-Tab in the Layer-Dialog. But i didn´t get it work with the code sniplets i found until now... (see the links above) – Astrid Oct 12 '17 at 13:13
  • I think you have two (similar) options after creating the dialog in Qt-Designer. (1) Write a python script with a function that opens your form. The function must connect the button click to the file dialog. You can then call this script directly from QGIS. (2) Do almost the same as in (1), but bundle the python code and the form into a QGIS plugin. Would you prefer (1) or (2)? – pschill Oct 13 '17 at 14:33

0 Answers0