Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. [Solved] How to Rendering an image within QwtPlot?

[Solved] How to Rendering an image within QwtPlot?

Scheduled Pinned Locked Moved 3rd Party Software
3 Posts 2 Posters 6.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shint
    wrote on 23 Mar 2011, 09:37 last edited by
    #1

    @
    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?

    1 Reply Last reply
    0
    • F Offline
      F Offline
      frankcyblogic.de
      wrote on 23 Mar 2011, 10:50 last edited by
      #2

      To show the pixmap:
      @
      void MyWidget::paintEvent(QPaintEvent* e) {
      QPainter(this).drawPixmap(0, 0, pixmap);
      }
      @

      The rest you find in the Qt documentation;)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        shint
        wrote on 24 Mar 2011, 04:40 last edited by
        #3

        first. thank you. unclewerner.

        i solved.

        reference example
        C:\Qt\qwt-5.2.1\examples\cpuplot

        [ check point ]

        1. edit ui. (create widget)
          Promoted Widgets
          QWidget - CWg_plot - wg_plot.h

        2. 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.)
          @

        3. 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());
          }
          @

        4. code in plotitem_bg (draw)
          @void CPlotitem_bg::draw(QPainter *p, const QwtScaleMap &, const QwtScaleMap &, const QRect &rect) const@

        1 Reply Last reply
        0

        1/3

        23 Mar 2011, 09:37

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved