📄 readme
字号:
-----------------------------------------------------------------------UPDATE: From version 5.0 onwards, the Qt OpenGL Extension includesdirect support for use of OpenGL overlays. For many uses of overlays,this makes the technique described below redundant. See the 'overlay'example program. The following is a discussion on how to use non-QGLwidgets in overlay planes.-----------------------------------------------------------------------Overlayrubber: An example program showing how to use Qt and Qt OpenGLExtension with X11 overlay visuals.(Background information for this example can be found in the file README.X11-OVERLAYS)The example program has three main parts:GearWidget: A simple QGLWidget that renders the usual gears. Modifiedso that it will print a debug message every time it redraws (renders)itself. Thus, you can eaily confirm that drawing in the overlay planedoes not cause redrawings in the main plane where the QGLWidgetresides.RubberbandWidget: Very simple standard (non-GL) Qt widget thatimplements rubberband drawing. Designed for use in an overlayplane. It takes the planes' transparent color as a constructorargument and uses that for its background color. Thus, the widgetitself will be invisible, only the rubberbands it draws will bevisible.main.cpp: Creates a GearWidget and a Rubberbandwidget and puts thelatter on top of the former. Contains a routine that checks that thedefault visual is in an overlay plane, and returns the transparentcolor of that plane.Running it:-----------Start the overlayrubber executable. Click and drag with the left mousebutton to see rubberband drawing. Observe that the QGLWidget doesnot redraw itself (no redraw debug messages are output), and yet theimage is not destroyed. Marvel at the coolness of X11 overlays!Using this technique in a real application------------------------------------------For clarity, this example program has been kept very simple. Here aresome hints for real application use:All normal widgets can go in the overlay plane: This means that youcan put all kinds of Qt widgets (your own or those provided with Qt)on top of the OpenGL image (widget), e.g. pushbuttons etc., and theycan be moved, resized, or removed without destroying the OpenGL image.Using with geometry management: The QLayout classes will not allow youto put one widget (the overlay) on top of another (the OpenGL widget);that would defy the whole purpose of the automatic layout. Thesolution is to add just one of them to the QLayout object. Have itkeep a pointer to the other (i.e. the QGLWidget knows about itsoverlay widget or vice versa). Implement the resizeEvent() method ofthe widget you put in the layout, and make it call setGeometry() onthe other widget with its own geometry as parameters, thus keeping thetwo widgets' geometries synchronized.Using with QPalette and QColorGroup: Instead of the somewhatsimplistic setBackgroundColor( transparentColor ), you can use Qt'sQPalette system for having your overlay widgets use transparent colorfor what you want. This way, the normal Qt widgets can be used asoverlays for fancy effects: just create a palette for them with thetransparent color for the wanted color roles, e.g. Background andBase, in the Normal and/or Active modes. This way, you can createsee-through QPushButtons etc.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -