Someone can suggest me a good, free, easy to use library for c++ that allow to draw a mathematical function in a window for microsoft windows? (e.g. the parabola x^2+5x+3=0)
Since you need a ready-made plotting widget, use Qwt.
It uses Qt.
You could use Qt directly as in contero's answer, without Qwt, as the task is simple enough. However, Qwt has lots of graph features built in, and the usage is straightforward.
I wrote a program similar to this using Qt. Qt is wonderful once you get it set up, but it may take a bit of effort if you've never used it (as will OpenGL, DirectX, etc..).
You can create a QImage and set it to whatever background color you want, then run your program through the width of the image pixel by pixel calling your function to get the y value. Roughly:
for (int i = 0; i < imageWidth; i++) {
image->setPixel(i, yourFunction(i), lineColor);
}
Once you've created your QImage, you can attach it to a QLabel using setPixmap(). Once you've attached it you can then display the image in a layout.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With