Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    [Solved] How to Rendering an image within QwtPlot?

    3rd Party Software
    2
    3
    5648
    Loading More Posts
    • 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
      shint last edited by

      @
      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 Reply Quote 0
      • F
        frankcyblogic.de last edited by

        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 Reply Quote 0
        • S
          shint last edited by

          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 Reply Quote 0
          • First post
            Last post