Struggling with QGLView examples
-
Hi everybody,
I'm want to load a model using OpenGL, so i decide to start with the teapot example, the problem is that i get this error that i can not solve:
error: no matching function for call to 'QGLView::QGLView(QWidget*&)' TeapotView(QWidget *parent = 0) : QGLView(parent), teapot(0) {}
I tried another examples and using the qglview library functions but i always get the same error. The only thing i could run was to draw a triangle writing the coordinates with the qlBegin() function.
Do i need to install another library to use qglview?
Thanks,
Andres -
Hi,
QGLView is part of the Qt 3D module. However, that module has not yet been released. It is currently undergoing a major rewrite.
However, if you are feeling adventurous, you could build the latest nightly version of Qt 3D yourself (pull it from the git repository). See http://comments.gmane.org/gmane.comp.lib.qt.devel/19832
-
You have two options:
Wait for Qt 3D to be released, OR
Compile the bleeding edge (unstable) version of Qt yourself
After that, you can run the teapot example.
-
You're welcome :)
Qt 3D incorporates Assimp, so the same options apply.
In addition, you can link your program directly to the Assimp library to load and display 3D models. See "Third Party Libraries":http://doc.qt.io/qt-5/third-party-libraries.html to find out how.
-
Hi again,
I tried what you told me before with an example linking directly to Assimp library, but I still have these errors:
undefined reference to `QOpenGLWidget::QOpenGLWidget(QWidget*, QFlagsQt::WindowType)'
...and many others refered to QOpenGLWidget. I tried to find out and i saw to add opengl to QT in pro, but nothing happened...
Any suggestion?
-
Can you post your full .pro file?
QOpenGLWidget is not in the "opengl" module. It is in the "gui" module. The "opengl" module is old and deprecated.
-
@
QT += core gui opengl xml
CONFIG += opengl
CONFIG += threadgreaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = TexturedCubeWithLightingFromBlender
TEMPLATE = appINCLUDEPATH += /home/amg/Qt/assimp-3.1.1/include
INCLUDEPATH += /home/amg/include/Qt3D
INCLUDEPATH += /home/amg/qt5/qtbase/src/widgets/kernel
INCLUDEPATH += /usr/include/qt5/QtOpenGL
LIBS += -L/home/amg/Qt/assimp-3.1.1/lib -lassimp
LIBS += -L/usr/lib/x86_64-linux-gnu -lGLUSOURCES += main.cpp
Dialog.cpp
Scene.cpp
MeshLoader.cpp
Cube.cppHEADERS += Dialog.h
Scene.h
MeshLoader.h
Cube.hFORMS += Dialog.ui
RESOURCES +=
Shaders.qrc
Textures.qrc@
-
Are you using Qt 5.4 ? QOpenGlWidget is only part of qt 5.4.
I think using the old qt 3d module is the best choice for you because with linking directly to assimp you can only load your model but you have to implement displaying and user interaction on your own. In qt 3d this is already done via QGLView.
If you want to use Qt 3d you have to compile and install it on your own.Thats very simple :
- Checkout the Qt 3d Source
- Open qt3d.pro and configure your settings (you can use shadow build)
- Compile
- After a successful compile you have to install that module to your qt installation
** Open Terminal and cd into your shadow build dir
** Type "make install" (or nmake install on windows) - After that you could use qt 3d module in any of your applications by adding 3d to your qt modules ( QT += 3d )
For loading Models look at http://qt-project.org/wiki/Loading-a-3D-Model
-
Ok, I will follow your instructions. First of all today I saw that it's available the Qt5.4 version, Do you recomend to install it? Actually i'm using assimp to load models, but i have more examples to follow under qt3d than assimp, and also better documents.
And now i understand why i got errors like 'no reference to QGLView', or 'Qt += 3d' not recognized.
Thanks euchkatzl!
-
Hi,
I tried to compile the qt3d.pro but i get a lot of errors... the first errors were about the includepaths, i modified and i get new errors like 'removeAll' function doesn't exists, or 'QAtomicInteger' does not name a type ... after i tried typing in a terminal:
qmake && make
...but i get new errors. Is there any trick/tip/whatever to do it?
Thanks
-
[quote author="avmg" date="1422377472"]
undefined reference to `QOpenGLWidget::QOpenGLWidget(QWidget*, QFlagsQt::WindowType)' [/quote]Try recompiling your Assimp project again with Qt 5.4 (the latest release).[quote author="avmg" date="1422473852"]I tried to compile the qt3d.pro but i get a lot of errors[/quote]Like I said before, if you want to compile Qt 3D, then you must first compile the bleeding edge (unstable) version of Qt. See http://comments.gmane.org/gmane.comp.lib.qt.devel/19832 -- you need to check out the 'dev' branch of each Qt repository from git. Qt 5.4 is too old. (Yes, the latest release is too old to build Qt 3D)
[quote author="avmg" date="1422460483"]i'm using assimp to load models, but i have more examples to follow under qt3d than assimp, and also better documents.[/quote]The Qt 3D documents are old and might be invalid though :( Remember: The developers are currently rewriting Qt 3D.
-
Hi again,
While the new Qt version is being developed, i decide to load the models using Assimp. Actually i'm able to load a 3Ds model and draw it in a glutWindow, but Is it possible to draw it in a QWidget?
I "painted" before some shapes using gl functions in a QWidget but not loaded models... -
[quote author="avmg" date="1422553516"]Actually i'm able to load a 3Ds model and draw it in a glutWindow, but Is it possible to draw it in a QWidget?
I "painted" before some shapes using gl functions in a QWidget but not loaded models...[/quote]I don't know, actually.How did you paint the shapes in QWidgets?
Try using "QOpenGLWidget":http://doc.qt.io/qt-5/qopenglwidget.html