|
QChartViewer drag&drop |
Posted by Gerald on Jan-03-2014 06:17 |
|
I would like to be able to drag&drop chart elements (e.g. bars or boxes) while using ChartDirector for those charts. I'm working with Qt and analysing the existing code in QChartViewer I found the following code snippet:
void QChartViewer::mousePressEvent(QMouseEvent *event)
{
onDelayedMouseMove();
if ((event->button() == Qt::LeftButton) && inPlotArea(event->x(), event->y()) &&
(m_mouseUsage != Chart::MouseUsageDefault))
{
// Mouse usage is for drag to zoom/scroll. Capture the mouse to prepare for dragging and
// save the mouse down position to draw the selection rectangle.
m_isPlotAreaMouseDown = true;
m_plotAreaMouseDownXPos = event->x();
m_plotAreaMouseDownYPos = event->y();
startDrag();
}
}
So this indicates that when using the Chart::MouseUsageDefault one does not get a signal about the mouse being pressed? And coordinates of the pressing spot wont get stored to be able to identify the underlying bar/box to be dragged?
Is there an improved version of that class existing (especially to prepare support for drag&drop)?
Are we allowed to modify that code and adapt to our needs (license)? |
Re: QChartViewer drag&drop |
Posted by Peter Kwan on Jan-04-2014 00:10 |
|
Hi Gerald,
According to the Qt documentation on QWidget, the standard QWidget does not have mouse press signals. To handle mouse press events, you would need to override the mousePressEvent handler. This is the same for QChartViewer, which is a subclass of QWidget. You can override the mousePressEvent handler as if it is a standard QWidget and handle the mouse press events in the standard way. You do not need to modify QWidget or QChartViewer to do this.
However, if you do want to modify QChartViewer for some reasons, you are allowed to do so. QChartViewer is released in source code format as part of the sample code, and like all sample code, the user is free to copy, modify and and use them in their own projects.
Hope this can help.
Regards
Peter Kwan |
|