how to drag and drop of a QwtPlotCurve inside the QwtPlotCanvas?



  • Hi @uwer,
    I want a user to change the position of QwtPlotCurve on QwtPlotCanvas (like drag and drop on the canvas)
    So, I did refer the ItemEditor example of the Qwt lib.
    How do I convert these lines for QwtPlotCurve instead QwtPlotShapeItem?
    In the

    bool Editor::moved(const QPointF& pos)
    {
    //you can assume above this code is  same as the example code 
    //only part of the code which is not understood by me, I'm asking here
    //I don't know to how to convert following codes according to QwtPlotCurve instead of QwtPlotShapeItem, please help me
    
    #if QT_VERSION>=0x040600
    const QPainterPath shape=d_editedItem->shape().translated(p2-p1);// I have declared d_editedItem as QwtPlotCurve* instead of QwtPlotShapeItem*
    #else
    const double dx=p2.x()-p1.x();
    const double dy=p2.y()-p1.y();
    QPainterPath shape=d_editedItem->shape();
    for(int i=0;i<shape.elementCount();i++)
    {
     const QPainterPath::Element &el=shape.elementAt(i);
     shape.setElementPositionAt(i,el.x+dx,el.y+dy);
    }
    #endif
    d_editedItem->setShape(shape);
    d_currentPos=pos;
    return true;    
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.