Setting up QCustomPlot

Setting up QCustomPlot

Getting QCustomPlot to work with your application is very easy:

  • Get the latest version of QCustomPlot from the download section.
  • Use the qcustomplot.h and qcustomplot.cpp file like any other ordinary class file

For QtCreator users

Right click on the root entry of your project in the left sidebar and choose Add Existing Files...

In the appearing file dialog, select the qcustomplot.h and qcustomplot.cpp files, to add them to your project. If this is done, your project structure and.pro file should look something like this:

If you are using Qt version 5.0 upwards, you need to add printsupport to the QT variable in your .pro file. In the case shown above, this is done after a greaterThan(QT_MAJOR_VERSION, 4) conditional. This makes sure the printsupport (and widgets) is not added when using older Qt versions.

The project is now ready to use QCustomPlot. Place a regular QWidget on your form in the desired location. Right click on it and hit Promote to...

In the appearing dialog, enter QCustomPlot in the input field next to Promoted class name. The input next to Header file should automatically fill with the correct qcustomplot.h value. Hit Add to add QCustomPlot to the promoted classes list and finally hit Promote to turn the QWidget on your form into a QCustomPlot.

You won't see any immediate visual changes in QtCreator (or QtDesigner), but while running the application, you will see an empty plot with axes and grid lines.

Using QCustomPlot as shared library .so/.dll

Using a shared library means to not include the .h/.cpp file into your project, but linking with an external qcustomplot.so (GNU/Linux) orqcustomplot.dll (MSWindows) file. QCustomPlot is ready to be built as a shared library by setting the compiler define QCUSTOMPLOT_COMPILE_LIBRARY. To use the shared library in your application, set the define QCUSTOMPLOT_USE_LIBRARY before including the QCustomPlot header.

The sharedlib package in the download section provides two projects that demonstrate this: one compiles the shared QCustomPlot library and the other uses the shared library. This should quickly get you started using QCustomPlot as a shared library.

Running the examples

The QCustomPlot.tar.gz package in the download section contains the example projects ready to be compiled. Just extract the whole package to a new directory, navigate inside the example directories and run qmake; make. Alternatively you can open the .pro files in QtCreator and work with the examples from there.


Linux

copy *.h to /usr/include/

copy *.so to /usr/lib/

Android NDK(not sure that's the correct loacation for that)

copy *.h to /android-ndk-r9c/sources/third_party/qcustomplot/include

copy *.so to /android-ndk-r9c/sources/third_party/qcustomplot/lib

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值