0

I would like to find way how to call plugin QFieldSync from Python console in QGIS.

2
  • What do you mean by "call"? Opening QFieldSync plugin window or do the all job without opening the plugin window from Python Console? – Kadir Şahbaz May 24 at 21:22
  • What have you tried so far and what were the results? – LaughU May 25 at 9:00
2

To open plugin GUI various dialog, you can try

from qgis import utils

qfieldsync_instance = utils.plugins.get('qfieldsync')

# Each below statements open a dialog box
qfieldsync_instance.show_synchronize_dialog()
qfieldsync_instance.show_project_configuration_dialog()
qfieldsync_instance.show_package_dialog()
qfieldsync_instance.show_preferences_dialog()

To use Package for QField without GUI, you can't simply use method package_project from "Create" button from the plugin instance as it's tied to GUI dialog (try utils.plugins.get('qfieldsync').push_dlg.package_project() to see it fail).

Instead, you can do the following

from qfieldsync.core import OfflineConverter

canvas = iface.mapCanvas()
project = QgsProject.instance()
offline_editing= True
export_folder = '/path/to/folder'

offline_convertor = OfflineConverter(project, export_folder, canvas.extent(), offline_editing)
offline_convertor.convert()

Not the answer you're looking for? Browse other questions tagged or ask your own question.