2

i am working with qgis c++ api 2.8.2 and qt4.8.5 i want to disable the rendering during zoom in or zoom out fonction in order to have a fast zoom i try to use :

MyMapCanvas->stopRendering(); 

and

MyMapCanvas->setRenderFlag(false);

before the call of zoomIn ou zoomOut method but the renderer seems to be already active

how can i disable it before a zoomIn or zoomOut operation ?

  • QGIS is has multi threaded rednering. It will handle that for you no need to start and stop the rendering. – Nathan W Dec 3 '15 at 3:56
1

i found the solution on the wheelevent of the mouse i do a zoomIn or a ZoomOut and i stop the rendereing and start a Qtimer to enable the rendering later, like 200ms, each time i move the wheel, the timer is started and the rendering was stopped it allow to have a veryf fast zoomin and zoomout and when there is no action on the wheel the rendering is started

here is a sample of the code to illustrate :

void CMyQgsMapCanvas::wheelEvent( QWheelEvent* pevent)
{
    setRenderFlag(false);
    stopRendering();
    mTimeForRender.start(100);
    if ( pevent->delta() > 0 ) {
        MyzoomOut();
    }
    else {
        MyzoomIn();
    }
}

the slot :

void CMyQgsMapCanvas::StartTheRender()
{
    setRenderFlag(true);
    mTimeForRender.stop();
}

the connect

connect(&mTimeForRender,SIGNAL(timeout()),this,SLOT(StartTheRender()));
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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