[Solved] How to Rendering an image within QwtPlot?
-
@
void plot::render()
{
QPixmap pixmap(":/prefix/line.png");
if(pixmap.isNull())
{
return ;
}QPainter painter(&pixmap); QRect rcSrc; rcSrc.setRect(0, 0, this->width(), this->height()); painter.drawPixmap(rcSrc, pixmap);
}
@[ Promoted Widgets ]
QGraphicsView - QwtPlot - qwt_plot.h[ plot.h ]
class plot : public QGraphicsView//
The image is not visible. please. help me.
How to Rendering an image within QwtPlot? -
To show the pixmap:
@
void MyWidget::paintEvent(QPaintEvent* e) {
QPainter(this).drawPixmap(0, 0, pixmap);
}
@The rest you find in the Qt documentation;)
-
first. thank you. unclewerner.
i solved.
reference example
C:\Qt\qwt-5.2.1\examples\cpuplot[ check point ]
-
edit ui. (create widget)
Promoted Widgets
QWidget - CWg_plot - wg_plot.h -
add code
@
CWg_plot* wg_plot = new CWg_plot(this); //create widget
wg_plot->resize(300, 300); //need resize
or (other way.)
CWg_plot* wg_plot = ui->wg_unit; //auto resize (follow ui.)
@ -
code in wg_plot
@
qwt_plot = new QwtPlot(this); //create plot
CPlotitem_bg* plot_bg = new CPlotitem_bg(); //create CPlotItem
plot_bg->attach(qwt_plot); //add CPlotitem in qwt_plot
@
and
@
void CWg_plot::resizeEvent(QResizeEvent* event) //plot resize
{
if(qwt_plot == NULL){ return ; }
qwt_plot->resize(this->width(), this->height());
}
@ -
code in plotitem_bg (draw)
@void CPlotitem_bg::draw(QPainter *p, const QwtScaleMap &, const QwtScaleMap &, const QRect &rect) const@
-