Qt C - How Add Point to map with clicked mouse ? screenToLocation failed nan

1217
2
Jump to solution
09-05-2017 12:54 PM
Juan_CarlosColchado_Casas
New Contributor II

my class Window_Map is the widget connect with mouse event and Slot my_clicked

void Window_Map::my_clicked(QMouseEvent &mouseEvent)
{


  if(mouseEvent.button()==Qt::LeftButton){
     auto mapPoint = _MapView->screenToLocation(mouseEvent.x(),mouseEvent.y());
     qDebug()<<" Punto :: "<<mapPoint;  // this show nan nan nan nan
  }
  else if(mouseEvent.button()==Qt::RightButton){
      _C.setShape(Qt::ArrowCursor);
      QGuiApplication::setOverrideCursor(_C);
      disconnect(_MapView,SIGNAL(mouseClicked(QMouseEvent&)),this,SLOT(s1(QMouseEvent&)));
  }
}

0 Kudos
1 Solution

Accepted Solutions
LukeSmallwood
Esri Contributor

Hi Juan,

I think the problem here is that you are directly printing the Point to qDebug(). The problem is that we do not support this operater for the Point type - so you are actually printing invalid geometry details. If you want to see a string representation of the point you can do something like:

qDebug()<<" Punto :: "<<mapPoint.toJson();

I hope that makes helps.

Luke

View solution in original post

2 Replies
LukeSmallwood
Esri Contributor

Hi Juan,

I think the problem here is that you are directly printing the Point to qDebug(). The problem is that we do not support this operater for the Point type - so you are actually printing invalid geometry details. If you want to see a string representation of the point you can do something like:

qDebug()<<" Punto :: "<<mapPoint.toJson();

I hope that makes helps.

Luke

Juan_CarlosColchado_Casas
New Contributor II
hello luke thank you very much for your help I hope to be able to share things also with you God bless you
0 Kudos