QT Super Fine drawing controls-Qcustomplot Overview and installation Tutorial

Source: Internet
Author: User

1. Overview

Qcustomplot is a super ultra-compact Qt drawing class, very beautiful, very easy to use, Only need to add a qcustomplot.h and qcustomplot.cpp files can be used, far more convenient and beautiful than QWT, you can use the two source files themselves can also be compiled into library files, very convenient.

Official website: http://www.qcustomplot.com/

1.0:http://download.csdn.net/detail/czyt1988/5986701

Here's a look at its super-powerful features:

1. Installation

Using Qcustomplot is very simple, just copy the Qcustomplot.cpp and qcustomplot.h to the project directory, and then bring the two files into the project

Right-click on the project to add the existing file, two files into the project

When the pro file is added on Qcustomplot.cpp and qcustomplot.h, you need to add a

QT + = Widgets Printsupport

Due to the use of printing related, so you need to join Printsupport, in the original widgets after the addition can

Then you can use the Qcustomplot.

To be able to use Qcustomplot in UI Designer, you can use a widget form on the UI designer, right-click on the form, select Promote to


The promotion of the class name to fill in Qcustomplot, so you can use, and we use the same as normal control, UI->XXX->

2. Drawing

The Qcustomplot drawing process is very, very simple. Similar to most of the drawing controls, the first need to draw a graph, or a layer, through the addgraph can add a graph layer, this function returns the graph layer pointer, or through the curve index to find, all the added curves are placed in a list, if it is the first one to add , then this index is 0,

Customplot->graph (0)

Of course, each curve is best defined by a name. Easy to find

You can use the SetName and name functions to set and get the name of the curve separately

You can set the data for this curve by adding the curve, Qcustomplot is very convenient for plotting the trend graph.

You can set the data directly using the function SetData.

voidSetData (Qcpdatamap*data, BOOLcopy= false)
voidSetData ( Constqvector< Double> &key, Constqvector< Double> &value)

Easily draw with a vector of X, Y, and so long

You can also append data

voidAddData ( ConstQCPDATAMAP&AMP;DATAMAP)
voidAddData ( ConstQcpdata&data)
voidAddData ( DoubleKey DoubleValue
voidAddData ( Constqvector< Double> &keys, Constqvector< Double> &values)

Qcustomplot This class of design is very clear, the degree of discretization is not high, very easy to use

You can set the X, Y axis after setting the data

Customplot->xaxis->setlabel ("X");
Customplot->yaxis->setlabel ("Y");

or set the range of the X, Y axes

Customplot->xaxis->setrange ( -1,1);
Customplot->yaxis->setrange (0,1);

If you don't know the scope, use it.

The Qcustomplot::rescaleaxes () function, which automatically sets the most appropriate display range, is very simple.

Display images after Setup is complete

Using the Qcustomplot::replot function to redraw the image, the show function also triggers the redraw event.

Effect:


When the image is not moved or zoomed out, the Qcustomplot can be easily moved and scaled down.

You can use the Qcustomplot function setinteractions

Setinteractions (Qcp::irangedrag | Qcp::irangezoom);

This makes it possible to move and scale.

QT Super Fine drawing controls-Qcustomplot Overview and installation Tutorial

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.