[Qgis-user] problem in writing plugin in c++

Bijay Panda bijaykumar.mail at gmail.com
Wed Feb 18 22:20:51 PST 2009


Hi All,
I am new to Qgis.I want to write a plugin to simply draw circle or a
polygon  in screen
when i load that plugin through plugin manager..Already i ve gone
through the process of writing plugins in c++.I also tested the point
converter plugin,but i want to start from a simple one like just to
draw somthing on screen which can be scaled(zoom in and out)..I
already tried it like below

void QgsPointConverterPlugin::initGui()
{
  // myQActionPointer = new QAction( QIcon( ":/scale_bar.png" ), tr(
"&Scale Bar" ), this );
  mAction = new QAction(tr("&Convert to point"), this);
  connect(mAction, SIGNAL(activated()), this, SLOT( run() ) );
  connect( qGisInterface->mapCanvas(), SIGNAL( renderComplete(
QPainter * ) ), this, SLOT( render(QPainter * )) );

  mIface->addToolBarIcon(mAction);
  mIface->addPluginToMenu(tr("&Convert to point"), mAction);
}

void QgsPointConverterPlugin::render(QPainter *painter)
{

  painter->setRenderHint(QPainter::Antialiasing, true);
  painter->setPen(QPen(Qt::black, 12, Qt::DashDotLine, Qt::RoundCap));
  painter->setBrush(QBrush(Qt::green, Qt::SolidPattern));
  painter->drawEllipse(10, 10, 100, 140);
}

It draws a ellipse which can't be scaled(zooming in and out not
working).It's like a static drawing(which has no effect with scaling )
above a layer of data .But I want it to be scaled as a normal layer .
Can any one help me out plz.

-- 
Thanks & Regards
Bijay



More information about the Qgis-user mailing list