Qt5.2.1+MathGL2.2.2.1+vs2010

一,所需文件:

    vs2010:http://pan.baidu.com/s/1mgr1Umk

    mathGL 2.2.2.1:http://mathgl.sourceforge.net/doc_en/Download.html#Download

    Qt5.2.1:http://qt-project.org/downloads

    CMake:http://www.cmake.org/cmake/resources/software.html

    第三方依赖库,zlib,png:http://pan.baidu.com/s/1jG0txsy


二,利用CMake工具生成vs2010工程

     整体步骤为,设置目录->configure->generate,如图:

 

 configure之前需做如下配置

  (1),配置第三方库png所在路径,共三个路径,如图:

 (2),配置第三方库zlib所在路径,共两个路径,如图:

(3),选择qt5 选项,如图:

三,编译工程mgl以及mgl-qt5,生成mgl.dll 以及mgl-qt5.dll,如图:

四,Qt调用mathGL实例。

工程配置如下:

(1)


(2)


(3)

测试代码:

 #include <QtWidgets/QApplication>
#include <QtWidgets/qmainwindow.h>
#include <QtWidgets/QScrollArea>
#include <mgl2/qmathgl.h>
#include <mgl2/mgl.h>

int sample(mglGraph *gr)
{
 mglData y;
 gr->Title("3d variant");
 gr->Rotate(50,60);
 gr->Box();
 mglData yc(30), xc(30), z(30); z.Modify("2*x-1");
 yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)");
 gr->Plot(xc,yc,z,"rs");
 return 0;
}

int main(int argc,char **argv)
{
 QApplication a(argc,argv);
 QMainWindow *Wnd = new QMainWindow;
 Wnd->resize(810,610); // for fill up the QMGL, menu and toolbars
 Wnd->setWindowTitle("QMathGL sample");
 // here I allow to scroll QMathGL -- the case
 // then user want to prepare huge picture
 QScrollArea *scroll = new QScrollArea(Wnd);
 // Create and setup QMathGL
 QMathGL *QMGL = new QMathGL(Wnd);
 //QMGL->setPopup(popup); // if you want to setup popup menu for QMGL
 QMGL->setDraw(sample);
 // or use QMGL->setDraw(foo); for instance of class Foo:public mglDraw
 QMGL->update();
 // continue other setup (menu, toolbar and so on)
 scroll->setWidget(QMGL);
 Wnd->setCentralWidget(scroll);
 Wnd->show();
 return a.exec();
}

执行效果:


整体工程:http://pan.baidu.com/s/1hqecPt6



  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值