[Qgis-developer] plugin zoom question

SJWC GIS sjwcgis at gmail.com
Wed Apr 25 13:41:16 EDT 2012


Nevermind; I found my issue.  I had an infinite recursion that was calling
the search function and recreating the QCompleter each loop.  That's why it
was crashing the application.  Again, thanks for the Console tip -- that
was invaluable.

Aaron


On Wed, Apr 25, 2012 at 9:28 AM, SJWC GIS <sjwcgis at gmail.com> wrote:

> Hi Bernhard,
>
> I tried again this morning (using the Python Console, which I didn't
> actually realize existed before your email) and sure enough, it worked.
>  I'm still having the problem, but I think I've been able to narrow it down
> a little better.  The method actually works when I'm using a push button to
> trigger it.  However, I'm also using a QCompleter to provide autocomplete
> functionality with a list of addresses.  When the QCompleter is activated
> (a value is selected) the program crashes.  This seems odd to me, since I
> can tell from the output that the whole method executes -- it crashes some
> time after I refresh the map canvas.  I don't think the map canvas refresh
> in itself crashes it (logging seems to indicate that that method finishes)
> but rather something related to my QCompleter's activate signal.  Any ideas
> on why this might be the case?
>
> In any case, thanks for your help...it got me a bit further down the
> stream.
>
> Aaron
>
>
> On Tue, Apr 24, 2012 at 11:43 PM, <bernhard.stroebl at jena.de> wrote:
>
>> Hi Aaron,
>>
>> the code works for me when entering it in the console directly (QGIS
>> 1.7.1/WinXP)
>> Maybe there is something wrong with your coordinates? Try to enter values
>> for x and y directly in the code and see if it works.
>>
>> Bernhard
>>
>> Am 25.04.2012 07:00, schrieb Denis Rouzaud:
>>
>>  Hi,
>>>
>>> How is defined self.plugin ?
>>>
>>> On 04/25/2012 01:30 AM, SJWC GIS wrote:
>>>
>>>> Hello all,
>>>>
>>>> I've written a piece of code that will search a database for a given
>>>> point, and then return that point so we can center the map canvas on
>>>> it and zoom in. Unfortunately, it's not working. QGIS crashes after
>>>> the code executes, leaving no error messages behind. Is there a better
>>>> way to center/zoom to a given point? I've tried the canvas method
>>>> "centerWithZoom" as well, with no success. (It also crashes.) I have
>>>> checked my coords -- they are in the proper projection (the same as
>>>> the mapCanvas) and I haven't reversed them. Any other ideas/methods of
>>>> accomplishing this are greatly appreciated. Thanks!
>>>>
>>>> Aaron
>>>>
>>>> x = result[0][1]
>>>> y = result[0][2]
>>>> xscale = 1.0
>>>>
>>>> # Get the map canvas
>>>> mc = self.plugin.iface.mapCanvas()
>>>>
>>>> height2 = mc.extent().height() * xscale / 2.0
>>>> width2 = mc.extent().width() * xscale / 2.0
>>>>
>>>> rect = QgsRectangle(x-width2,y-**height2,x+width2,y+height2)
>>>>
>>>> # Set the extent to our new rectangle
>>>> mc.setExtent(rect)
>>>>
>>>> # Refresh the map
>>>> mc.refresh()
>>>>
>>>>
>>>>
>>
>> ________ Information from NOD32 ________
>> This message was checked by NOD32 Antivirus System for Linux Mail Server.
>> http://www.nod32.com
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20120425/a4415f83/attachment.html


More information about the Qgis-developer mailing list