Attached a code example for drawing a
line with the QT C++ OpenGLWidget.
This is the first example that lives on the internet which can draw a line with the new OpenGLWidget trough a
input field and execute button. I am proud to provide this bare basic code example on this forum !
It will be looked and downloaded by many people all over the world over the coming years. I think programming student's are
very happy with this code example. It's a nice start.
The example is clean written so user's can verify the code quite easy.
1. You can insert a value in the gui input text box. This value is limited to float value's with 2 decimal's accuracy.
2. The value of the input box is passed trough a
extern variable to a different C++ file that does the OpenGL code.
3. The button passes the new value into the variable.
4. Screen is updated with timer function.
5. Provided is a basic zoom in and zoom out function that can be connected to the gui.
6. The file's are commented.
7. This example can be expanded to a g-code generator or a cad program.
8. A picture resource file example is provided.
9. Do not use a extern variable name like x for testing. This x is already used in OpenGL code, the error it will give will result in scratching your head a few hours. Use a name like xx or xvalue instead.
10. The application has a console output.
11. The code is working with latest QT release 5.12.3
Screen shot of the program output :
The QT C++ project files are attached. To open the project in QT select the .pro file.
To install QT, visit :
www.qt.io/download
To try the already compiled program, unzip the untitled.zip file and type in terminal : ./untitled
@Maximilian,
I have to think about your suggestion "over the top".