QCustomPlot Discussion and Comments

Move Items in PlotReturn to overview
July 13, 2013, 21:00
by Mostafa Alizadeh

Hi, Is there any way to move items (e.g TextItem or EllipseItem) in plot area by mouse?

July 14, 2013, 00:04
by DerManu

You will have to react to the mouse signals of QCustomPlot. Further, the method QCustomPlot::itemAt will prove helpful here, as it returns the item at a certain pixel position.

So on a mouse press event you check whether an item is under the cursor. If so, go into "item drag mode" (i.e. make a variable that holds the currently pressed QCPAbstractItem*). Upon mouse move events, move the item (if not 0), upon mouse release events, set the drag item variable back to 0. That's the basic idea.

July 17, 2013, 11:50
by michel

I agree, implemented this way it works

but,
it would be very interesting to have this code embedded in the item object, to reuse the component.
an item set to "movable" could be moved if selected first, and signal position changed

In fact something as the selection mechanism implemented today

July 17, 2013, 12:05
by DerManu

Yeah, I've been thinking about something similar, I'll put it on the todo list. However this will mean an event interface for items (like for QCPLayoutElements currently). I'll see whether it makes sense putting it in the 1.0.0, or whether it will have to wait for 2.0.0.

July 17, 2013, 14:14
by Mostafa Alizadeh

Thank you Emanuel :)

July 17, 2013, 14:26
by michel

great!

as all that project :)

for the moment, sub-classing from QCustomplot a class encapsulating some specific(s) movable(s) item(s) can do the job ;)

July 17, 2013, 15:08
by michel

great!

as all that project :)

for the moment, sub-classing from QCustomplot a class encapsulating some specific(s) movable(s) item(s) can do the job ;)

September 19, 2014, 03:22
by xueyoo

how about the current status for this new feature?

October 8, 2021, 20:16
by Ali Abd

hi DerManu
did you add this feature to new version?
can you explain it to us please

July 24, 2023, 02:55
by ZacDu

I made the codes myself to use for my project.

You can move text item, arrow and wave bracket by mouse.
And you can resize the arrow and wave bracket by mouse.

I posted those on github : https://github.com/jcsu1835/QCustomPlot

I hope this will be helpful.

AltStyle によって変換されたページ (->オリジナル) /