[QGIS-Developer] Using QgsMapCanvas in a python plugin dialog

Tim Sutton tim at kartoza.com
Wed Apr 24 02:41:36 PDT 2019


Thanks so much for sharing your solution Eric - it makes the mailing list archives all the more useful!

Regards

Tim

> On 24 Apr 2019, at 01:18, Eric Brelsford <ebrelsford at gmail.com> wrote:
> 
> I believe I got this working by making the mapLayers a member of the dialog rather than a variable created in show(). For anyone who is curious or runs into this in the future, this commit worked for me:
> 
>   https://github.com/ebrelsford/qgis-map-canvas-test/commit/3bf48449aaf8430d03dad58c54a80c227c2852c1 <https://github.com/ebrelsford/qgis-map-canvas-test/commit/3bf48449aaf8430d03dad58c54a80c227c2852c1>
> 
> eric
> 
> On Mon, Apr 22, 2019 at 7:42 PM Eric Brelsford <ebrelsford at gmail.com <mailto:ebrelsford at gmail.com>> wrote:
> I'm unsuccessfully trying to use a QgsMapCanvas in a python plugin's dialog.
> 
> The canvas renders the map, which appears and disappears the first time I load the dialog. The second time I load the dialog, the map is rendered and remains. However, I've only accomplished this by using waitWhileRendering(), which I know is incorrect.
> 
> I have posted a minimal plugin on GitHub (https://github.com/ebrelsford/qgis-map-canvas-test/ <https://github.com/ebrelsford/qgis-map-canvas-test/>) demonstrating this issue. It was created using Plugin Builder. The relevant parts will be the .ui file:
> 
>   https://github.com/ebrelsford/qgis-map-canvas-test/blob/master/map_canvas_test_dialog_base.ui#L15 <https://github.com/ebrelsford/qgis-map-canvas-test/blob/master/map_canvas_test_dialog_base.ui#L15>
> 
> and the dialog python file:
> 
>   https://github.com/ebrelsford/qgis-map-canvas-test/blob/master/map_canvas_test_dialog.py#L55 <https://github.com/ebrelsford/qgis-map-canvas-test/blob/master/map_canvas_test_dialog.py#L55>
> 
> Is anyone familiar with what I'm doing wrong here? Or does anyone know python plugins using QgsMapCanvas in the dialog that I could use as a reference? I'd appreciate any thoughts you have on it!
> 
> eric
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

—









Tim Sutton

Co-founder: Kartoza
Ex Project chair: QGIS.org

Visit http://kartoza.com <http://kartoza.com/> to find out about open source:

Desktop GIS programming services
Geospatial web development
GIS Training
Consulting Services

Skype: timlinux 
IRC: timlinux on #qgis at freenode.net

I'd love to connect. Here's my calendar link <https://calendly.com/timlinux> to make finding time easy.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190424/e1bf0030/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: KartozaNewLogoThumbnail.jpg
Type: image/jpeg
Size: 6122 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190424/e1bf0030/attachment-0001.jpg>


More information about the QGIS-Developer mailing list