qt Drawing plugin qcustomplot download installation configuration use

Source: Internet
Author: User



First, configure the Qcustomplot

Official: Http://www.qcustomplot.com/index.php/download

650) this.width=650; "Src=" http://img.blog.csdn.net/20151010144651708?watermark/2/text/ Ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/southeast "style= "Border:none;"/>

Unzip the file after downloading (do not have Chinese path)

Open QT, create a new form project

Copy the header file Qcustomplot.h and source files from the extracted folder to the project folder Qcustomplot.cpp

In Qt, add the existing files, enter the header file qcustomplot.h and the promotion class name into "Qcustomplot", click Add Source file Qcustomplot.cpp add to the project

650) this.width=650; "Src=" http://img.blog.csdn.net/20151010150356138?watermark/2/text/ Ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/southeast "style= "Border:none;"/>

Add a printsupport to the project Pro

650) this.width=650; "Src=" http://img.blog.csdn.net/20151010150556149?watermark/2/text/ Ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/southeast "style= "Border:none;"/>

Open the interface file, enter the UI, add a widget area to the main window, right-click on the widget area you added, and select the "Promote to" button

650) this.width=650; "Src=" http://img.blog.csdn.net/20151010150654879?watermark/2/text/ Ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/southeast "style= "Border:none;"/>

Promote class name enter "Qcustomplot", click Add

650) this.width=650; "Src=" http://img.blog.csdn.net/20151010150825906?watermark/2/text/ Ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/southeast "style= "Border:none;"/>

Click Promote to complete the configuration


Second, the use of Qcustomplot

Principle:

Qcustomplot can understood as is a drawing board class, which inherits from Widgets, the Widget class in the interface is promoted to Qcustomplot to be able to draw

each curve in the Qcustomplot is a Graph objects, which are related to the display of data, we manipulate graph or invoke the method provided by the graph object

There are four axes in a qcustomplot, of which Xaxis and the YAxis is the x and Y axes we see, there are two axes xAxis1 and yAxis1 for the x and Y coordinates above and to the right, which are hidden by default and can be programmed to display


then the above operation, First, rename the object above the container interface promoted to the Qcustomplot class to Qcustomplot

Add the following code to the main class widget constructor to draw a standard standard y=x^3 curve

[CPP] view plain copy

  1. Widget::widget (Qwidget *parent):

  2. Qwidget (parent),

  3. UI (new ui::widget)

  4. {

  5. UI->SETUPUI (this);

  6. //Define two variable arrays to hold the coordinate data of the drawing   

  7.      qvector<double > x (101), Y ( 101); / /storing data for x and Y coordinates, 101 for data length    

  8.      //add data, we show here y=x^3, for positive and negative symmetry, we x from 10 to +10 &NBSP;&NBSP;

  9. for (int i=0;i<101;i++)

  10. {

  11. X[i] = I/5-10;

  12. Y[i] = x[i] * x[i] * x[i];

  13. }

  14. //Add a curve to the drawing area qcustomplot (lifted from the widget)   

  15. Ui->qcustomplot->addgraph ();

  16. //Add Data   

  17. Ui->qcustomplot->graph (0)->setdata (x, y);

  18. //Set axis label name   

  19. Ui->qcustomplot->xaxis->setlabel ("x");

  20. Ui->qcustomplot->yaxis->setlabel ("y");

  21. //Set the axis display range, otherwise we can only see the default range   

  22. Ui->qcustomplot->xaxis->setrange ( -11,11);

  23. Ui->qcustomplot->yaxis->setrange ( -1100,1100);

  24. //Redraw, not available here, official example, auto redraw after executing SetData function   

  25. //I think it should be used for dynamic display or for dynamic display after changing the axis range, we'll explore   

  26. //ui->qcustomplot->replot ();   

  27. }


Compile


650) this.width=650; "Src=" http://img.blog.csdn.net/20151010151429374?watermark/2/text/ Ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/southeast "style= "Border:none;"/>



Finally, I encountered an error here during the operation

650) this.width=650; "Src=" http://img.blog.csdn.net/20151010151513497?watermark/2/text/ Ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/southeast "style= "Border:none;"/>

Will

[CPP] view plain copy

    1. #include ". /.. /qcustomplot.h "

Change into


[CPP] view plain copy

    1. #include <qcustomplot.h>   


You can do it.


qt Drawing plugin qcustomplot download installation configuration use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.