Hello,
I want to draw a circle/square/rectangle on qwtpolt using the mouse, so the user can draw it anywhere on the polt with any size he wants.
is there any way or idea of how can i do it ???
Thank you,
Jesse
Hello,
I want to draw a circle/square/rectangle on qwtpolt using the mouse, so the user can draw it anywhere on the polt with any size he wants.
is there any way or idea of how can i do it ???
Thank you,
Jesse
Maybe you are looking for QwtPlotPicker.
Uwe
I am still learning about qwt, do you know any example or could you explain more of how can i use the PoltPicker ??
I know it gives the mouse pos for me, but how i show a square that gets bigger as the user drag the mouse more??
just the like the way when u draw a square in the painter.
thank you
F.e every QwtPlotZoomer is a picker that draws a rectangle.
Uwe
i was looking at the bode example, it does has a piker with zoomer.
which is using (QwtPicker::RectRubberBand) .. // "d_zoomer[0]->setRubberBand(QwtPicker::RectRubberBand);"
but i dont need the zoomer and i want the rect to stay on the canvas when i draw it.
so i think i need a piker and set its rubber band to rect rubberband, but how i make the rect stays on the plot ??
thank you so much
Added after 13 minutes:
I use a piker to give me the the mouse position
Qt Code:
picker->setStateMachine(new QwtPickerTrackerMachine); // i added these lines not sure if this is the way tho ???To copy to clipboard, switch view to plain text mode
i have this piker and set the rubberband to rect rubber
how i active it or disactive it ?? i mean make show and stay on the polt? and how i get its points ?
Thank you
Last edited by jesse_mark; 26th September 2012 at 15:51.
i edite my code and i was able to see the rect on my plot, but when i finisd the rect disappear , i would like to keep it shown and have access to its valus(points)
Qt Code:
// picker->setStateMachine(new QwtPickerTrackerMachine); To copy to clipboard, switch view to plain text mode
Implement a custom QwtPlotItem that will represent your rectangle. Use a QwtPlotPicker (or QwtPicker) to allow the user to choose a rectangle. Once the selection is complete, create an instance of your plot item and place it on the plot.
embeddedmz (26th May 2021)
Thank Wysota,
I used QwtPlotPicker and as i read from the qwtplotpicker a selected signal we be emitted once the selection is done.
so i connected it like:
Qt Code:
// [I]this[/I] is the MainWin connect(plot->picker,SIGNAL(selected(QVector<QPointF>)),this,SLOT(DrawSelection(QVector<QPointF> SelectionPoints)));To copy to clipboard, switch view to plain text mode
and i have the slot on the mainwindow
Qt Code:
void MainWin::DrawSelection(QVector<QPointF> SelectionPoints) { /// draw the points }To copy to clipboard, switch view to plain text mode
but im the single is not emitted
and when i run it can see the slot saying >>]Qt Code:
[I]object::connect: No such slot MainWin::DrawSelection(QVector<QPointF> SelectionPoints)[/ITo copy to clipboard, switch view to plain text mode
so can u please let me know what is the mistake im making ??
Thanks
Last edited by jesse_mark; 26th September 2012 at 22:03.
I think the message is pretty much self explanatory -- you don't have a slot called "DrawSelection" in your "MainWin" class. Usually this means you either forgot the Q_OBJECT macro or you didn't declare the method as a slot.
I do have this method in the MainWin header under
public slots:
void DrawSelection( QVector<QPointF> SelectionPoints);
and i do have other methods using them as slots and i have no problem.
but what do u exactly mean by Q_OBJECT macro ? I have have Q_OBJECT in header, but to be honest i don't really know exactly what its for .
Ah, I read the error message again and I noticed what was wrong. Remove the variable name from the slot signature in the connect() statement.
Bookmarks