Hi, Is there any way to move items (e.g TextItem or EllipseItem) in plot area by mouse?
Hi, Is there any way to move items (e.g TextItem or EllipseItem) in plot area by mouse?
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.
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
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.
Thank you Emanuel :)
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 ;)
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 ;)
how about the current status for this new feature?
hi DerManu
did you add this feature to new version?
can you explain it to us please
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.