avoid this message : "The constructor with a shareWidget is deprecated, use the regular contructor instead."

Asked by Luc OGER on 2020-06-29

Dear sir,

It i not a crucial point... but I want to avoid having this warning message at each run of a yade script:"The constructor with a shareWidget is deprecated, use the regular contructor instead."
I am using the latest compiled version of yade from june : 2020-06-23.git-f03a37c on Opensuse 15.1

how and where to modifiy things to do it?


Question information

English Edit question
Yade Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
Jérôme Duriez (jduriez) said : #1


I guess it comes from graphical-display-related files like this one [*], which should be updated to account for a new behaviour of some third party library. At least, that message does not come directly from YADE [**]


mkdir Test
cd Test
git clone https://gitlab.com/yade-dev/trunk.git
cd trunk
grep -r 'The constructor with a shareWidget is deprecated, use the regular contructor instead.' # returns nothing

Luc OGER (luc-oger) said : #2

Dear Jérôme

thanks for the hint where to find the 'solution': it is effectively inside the libQGLviewer 2.7.0 to 2.7.2 library, especially inside the qglviewer.cpp:

#ifndef DOXYGEN
/*! These contructors are deprecated since version 2.7.0, since they are not
 * supported by QOpenGlWidget */

/*! Constructor. See \c QGLWidget documentation for details.

All viewer parameters (display flags, scene parameters, associated objects...)
are set to their default values. See the associated documentation.

If the \p shareWidget parameter points to a valid \c QGLWidget, the QGLViewer
will share the OpenGL context with \p shareWidget (see isSharing()). */
QGLViewer::QGLViewer(QWidget *parent, const QGLWidget *shareWidget,
                     Qt::WindowFlags flags)
    : QOpenGLWidget(parent, flags) {
  qWarning("The constructor with a shareWidget is deprecated, use the regular "
           "contructor instead.");

now I will try to find a solution....

Luc OGER (luc-oger) said : #3

just some complementary inormation:
"After Qt 5.3's introduction of QQuickWidget, Qt 5.4 adds QOpenGLWidget, the long-awaited replacement for the legacy QGLWidget" from https://www.qt.io/blog/2014/09/10/qt-weekly-19-qopenglwidget

so I will try to modify /gui/qt5/GLViewer.cpp according to the new specification by eliminating the shareWidget

Luc OGER (luc-oger) said : #4

here my modification which avoid the warning and still generates a graphical view :

line 64-65:

GLViewer::GLViewer(int _viewId, const shared_ptr<OpenGLRenderer>& _renderer, QOpenGLWidget* parent)
        : QGLViewer(/*parent*/ (QWidget*) parent)

line 92:
 GLViewer(int viewId, const shared_ptr<OpenGLRenderer>& renderer, QOpenGLWidget* Widget = 0);

line 56:
  views.push_back(shared_ptr<GLViewer>(boost::make_shared<GLViewer>(0, renderer, /*QopenGLWidget*/ (QOpenGLWidget*)0)));

Jérôme Duriez (jduriez) said : #5

Thanks for sharing Luc, maybe it would help for possible future integration of this to (one choice to pick, increasing complexity)

- send the output of a (git) diff to <email address hidden>

- join YADE development on GitLab, see https://yade-dem.org/doc/gitrepo.html to start with (you probably also need to send an email asking to join the yade-dev gitlab team with your gitlab account)