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.
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.
Thanks the error message not there, but the signal is not triggred , after i do my selection the rect and every thing but the signal is not triggered??
OK i found in the bode example that come with the qwt library
used a picker and the selected signal
this way :
Qt Code:
// mainwindow header private Q_SLOTS: //mainwindow cpp ... .... .... { qDebug()<<" I got triggred "; ................ }To copy to clipboard, switch view to plain text mode
this signal was triggered fine, but why the
connect(picker, SIGNAL(selected(const QVector<QPointF> &)), SLOT(DrawSelection(const QVector<QPointF> &)));
was not triggered ???
Last edited by jesse_mark; 27th September 2012 at 16:09.
You probably have a Rect picker, not a Point picker machine attached to the picker.
jesse_mark (27th September 2012)
Bookmarks