?? overlay_x11.doc
字號:
/*! \page opengl-overlay-x11-example.html \ingroup opengl-examples \title OpenGL Overlay X11 Example\warning 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 \linkopengl-overlay-example.html overlay\endlink example program. Thefollowing is a discussion on how to use non-QGL widgets in overlayplanes.Overlayrubber: An example program showing how to use Qt and Qt OpenGLExtension with X11 overlay visuals.See \c{$QTDIR/examples/opengl/overlay_x11} for the source code.Background information for this example can be found in theinformation on \link opengl-x11-overlays.html overlays\endlink. The example program has three main parts:\list 1\i \e GearWidget - a normal, simple QGLWidget. This renders the usualgears. It has been modified to print a debug message every time itredraws (renders) itself. Thus, you can easily confirm that drawing inthe overlay plane does not cause redrawings in the main plane wherethe QGLWidget resides.\i \e RubberbandWidget - Very simple standard (non-GL) Qt widget thatimplements rubberband drawing. Designed for use in an overlay plane.It takes the plane's transparent color as a constructor argument anduses that for its background color. Thus, the widget itself will beinvisible, only the rubberbands it draws will be visible.\i \e{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.\endlist\section1 Running the ExampleStart the \c overlayrubber executable. Click and drag with the leftmouse button to see rubberband drawing. Observe that the QGLWidgetdoes not redraw itself (no redraw debug messages are output), and yetthe image is not destroyed. Marvel at the coolness of X11 overlays!\section1 Using this technique in a real applicationFor clarity, this example program has been kept very simple. Here aresome hints for real application usage:\list\i \e{All normal widgets are in the overlay plane.} This means that youcan put all kinds of Qt widgets (your own or standard Qt widgets) ontop of the OpenGL image (widget), e.g. pushbuttons etc., and they canbe moved, resized, or removed without destroying the OpenGL image.\i \e{Using with geometry management.} The QLayout classes don't permitputting one widget (the overlay) on top of another (the OpenGLwidget); that would defy the whole purpose of the automatic layout.The solution 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.\i \e{Using together with QPalette and QColorGroup.} Instead of thesimplistic setBackgroundColor( transparentColor ), you canuse Qt's QPalette system to make your overlay widgets usetransparent color for what you want. This way, the normal Qt widgetscan be used as overlays for fancy effects. Just create a palette forthem with the transparent color for the relevant color roles, e.g.Background and Base, in the Normal and/or Active modes. This way, youcan create see-through QPushButtons etc.\endlist*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -