Double buffering, getting started

Open GL version 1, Centos, C++
Please allow for typos as I cannot copy from my work computer to my internet computer.
Summary: What is the method to define buffers to swap in double buffering?
Details:
I am working on a strip chart that is always 2D and does not use any matrices. Several places have examples of double buffering.
In my init code is

#ifdef GL_DOUBLE_BUFFER
   glutInitDisplayMode( GL_DOUBLE )
#endif

And at the end of the drawing function

#ifdef GL_DOUBLE_BUFFER
   glSwapBuffers();
#else
   glFlush()
#endif

The app starts then quickly exits with the complaint:
Function called with no current window defined.
I have found several sites with example code, but did not recognize the line(s) of code that define windows for the swap function.

Look at any simple GLUT program. The initialisation sequence is usually quite similar to:

        glutInit(&argc, argv);

        glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
        glutInitWindowSize(800, 600);
        glutCreateWindow("Whatever");
        glutDisplayFunc(display);
        glutReshapeFunc(resize);

The parameters may change (window size, window name, if you aren’t using depth testing you don’t need GLUT_DEPTH), but you would normally call those functions in that order.

In particular, you can’t call any OpenGL functions until you’ve called glutCreateWindow, because you need a context and a context is created along with the window. glutInitDisplayMode and glutInitWindowSize need to be called before glutCreateWindow.

Ideally, OpenGL functions should only be called from the display callback (the resize callback sometimes calls glViewport and possibly sets up the projection matrix, but those can be done in the display callback). Event callbacks (mouse, keyboard, timer, etc) should normally just update the program state then call glutPostRedisplay to trigger redisplay rather than attempting to update the window in the event callback.

I am making major changes and need to get working again before I worry about double buffer.
However,…, regarding that quoted phrase, maybe I have another fundamental error.
This is a strip chart application. Samples (measurements to be displayed) arrive from a telemetry stream asynchronously. The Open GL is a QGLWidget residing within a Qt environment. I use a Qt timer running at 20Hz to call the display function. The chart is completely repainted on every Qt timer call. Open GL has no idea of when it needs to update. The user really has little control.
Is this an Ok strategy? Or might I need more changes? Is this too far off topic and a new thread is merited?

In which case, GLUT isn’t relevant. It can’t be used in conjunction with other GUI toolkits. For QGLWidget, double-buffering is controlled by the QGLFormat object passed to the constructor, and is enabled by default. If you’re getting flickering, you may need to change certain Window attributes. Digging up some old code which uses Qt4, I have

        setAttribute(Qt::WA_NativeWindow);
        setAttribute(Qt::WA_NoSystemBackground, false);
        setAttribute(Qt::WA_OpaquePaintEvent);

To redraw the widget, call its update method. This will end up calling the paintGL method; this is a virtual method which should be overridden in a subclass, and is equivalent to GLUT’s display callback.