manpagez: man pages & more
info mathgl
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.1.4 Using QMathGL

MathGL have several interface widgets for different widget libraries. There are QMathGL for Qt, Fl_MathGL for FLTK in MathGL v.1.8. These classes provide control which display MathGL graphics. Unfortunately there is no uniform interface for widget classes because all libraries have slightly different set of functions, features and so on. However the usage of MathGL widgets is rather simple. Let me show it on the example of QMathGL.

First of all you have to define the drawing function or inherit a class from mglDraw class. After it just create a window and setup QMathGL instance as any other Qt widget:

    int main(int argc,char **argv)
    {
        QApplication a(argc,argv);
        QMainWindow *Wnd = new QMainWindow;
        Wnd->resize(650,480);  // for fill up the QMGL, menu and toolbars
        Wnd->setWindowTitle(title);
        // 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, NULL);
        // or use QMGL->setDraw(foo); for instance of class Foo:public mglDraw
        QMGL->update();

        // continue other setup (menu, toolbar and so on)
        makeMenu();
        scroll->setWidget(QMGL);
        Wnd->setCentralWidget(scroll);
        Wnd->show();
        return a.exec();
    }

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2025
Individual documents may contain additional copyright information.