ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Right click on a chart
Posted by Nishant Sharma on Apr-04-2019 18:27
Attachments:
Hi,
I am looking at the qtdemo/qtdemo application.
It has a file (hitspotdialog.cpp) which handles the image map (attached hereby)

When we click or right click an element of say any pie chart, then the hotsport dialog comes up.
I want to distinguish between a right click and a left click. How can I do that?
On left click I want to do some operation and on right click I want to show some menu.
Screenshot_8.jpg

  Re: Right click on a chart
Posted by Peter Kwan on Apr-05-2019 00:27
Hi Nishant,

In the qtdemo sample code, when the mouse is clicked, it calls OnChartViewer:

connect(chartViewers[i], SIGNAL(clicked(QMouseEvent*)), SLOT(onChartClicked(QMouseEvent*)));

In the OnChartViewer, it pops up the HotSpotDialog:

void QTDemo::onChartClicked(QMouseEvent *event)
{
      ... code to pop up HotSpotDialog
}

You can add code to check if the mouse button is left or right button and do different things, like:

void QTDemo::onChartClicked(QMouseEvent *event)
{
     if (event->button()==Qt::RightButton)
    {
        ... code to pop up HotSpotDialog
    }
    else
    {
        ... code to do something else
    }
}

Hope this can help.

Regards
Peter Kwan