Closed ytyisme closed 7 years ago
I am not sure what you mean in this issue. Do you want me to remove the paintEvent
that I implemented in the widget? In my implementation, I need paintEvent
in order to paint the selection rectangle with QPainter
. Since the OSG widget displays a mixture of both 3D graphics (OpenSceneGraph) and 2D graphics (QPainter
), I thought that this was the best solution. The Qt documentation states that this makes sense, as far as I understand.
Now, in the windows platform,can’t display the things QPainter draw when use your code. My English is poor. Most of them are from google translation
I am sorry, I do not have much experience with programming for Microsoft Windows. I will try to look into this. Can you send me some screenshots maybe?
Now show the correct under Windows I modified as follows
class OSGWidget : public QOpenGLWidget,protected QOpenGLFunctions
void OSGWidget::paintGL()
{
glPushAttrib(GL_ALL_ATTRIB_BITS);
glPushClientAttrib(GL_ALL_ATTRIB_BITS);
viewer_->frame();
glPopAttrib();
glPopClientAttrib();
}
Under Windows, you need to add the link library opengl32.lib
Thank you for these modifications! Is the protected QOpenGLFunctions
required?
If you do not inherit QOpenGLFunctions
then the OpenGL
function will not be declared. You may need to include the gl.h
header file
Thank you for the reply! I will refer to this discussion in the README file because, as I said, I do not have sufficient experience with programming for Microsoft Windows.
This URL (http://doc.qt.io/qt-5/qopenglwidget.html)show Draw 2D graphics onto a QOpenGLWidget subclass using QPainter.I don't konw why you reimplement the paintEvent() and call makeCurrent() and doneCurrent().
Install Qt5.9.1 with examples, you will find one example qopenglwidget in Qt5.9.1\Examples\Qt-5.9.1\opengl. qopenglwidget is a example show how to Draw 2D graphics onto a QOpenGLWidget subclass using QPainter.I tried to modify your code to make it look like that example. I remove paintEvent(),and put QPainter in paintGL(), but it not works.
You can try it.