QVTKOpenGLWidget - which library?



  • Hi all,

    I am trying to integrate a VTK render window in a Qt GUI. Using QtCreator/Designer, I added an openGLWidget to the MainWindow and promoted it to QVTKOpenGLWidget. When I try to compile, the compiler does not find the header "QVTKOpenGLWidget.h". After I manually added this header to the project, the linker apparently does not find the right library and gives the error:

    /home/christian/InSync/Tmp/build-Viewer3D-Desktop_f4eeec-Debug/ui_mainwindow.h:42: error: undefined reference to `QVTKOpenGLWidget::QVTKOpenGLWidget(QWidget*, QFlags)'

    I added first the vtk libraries that appeared most likely to contain QVTKOpenGLWidget, later ALL vtk libraries, but the problem persists.

    In which library is the QVTKOpenGlWidget located?

    Also, if anyone could point me to an example project that uses QVTKOpenGLWidget, I would greatly appreciate it.

    I am using Qt 5.9.5 and VTK 7.1

    Thanks, Christian



  • When using VTK, and/or ITK, it's much easier to include the correct directories and libraries if you use CMake/CMakeLists.txt for the configuration instead of .pro project files.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    QVTKOpenGLWidget is provided by VTK. You have examples over here that should help you get started.



  • @SGaist
    Thank you for the examples! One warning ahead: In the preview of this post it seems that the font is randomly set to large in some parts, this is not intended (I could not figure out how to prevent it).
    Trying the examples, I basically run into the same problem, so I am wondering if my VTK installation is OK.

    When I untar the BorderWidgetQt archive from the example and execute cmake from the "build" directory, I get:

    ==============
    christian@christian-white:~/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/build$ cmake ..
    -- The imported target "vtkRenderingPythonTkWidgets" references the file
       "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so"
    but this file does not exist.  Possible reasons include:
    * The file was deleted, renamed, or moved to another location.
    * An install or uninstall procedure did not complete successfully.
    * The installation package was faulty and contained
       "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake"
    but not all the files it references.
    
    -- The imported target "vtk" references the file
       "/usr/bin/vtk"
    but this file does not exist.  Possible reasons include:
    * The file was deleted, renamed, or moved to another location.
    * An install or uninstall procedure did not complete successfully.
    * The installation package was faulty and contained
       "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake"
    but not all the files it references.
    
    -- The imported target "pvtk" references the file
       "/usr/bin/pvtk"
    but this file does not exist.  Possible reasons include:
    * The file was deleted, renamed, or moved to another location.
    * An install or uninstall procedure did not complete successfully.
    * The installation package was faulty and contained
       "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake"
    but not all the files it references.
    
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/build
    christian@christian-white:~/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/build$ 
    ==========================
    

    So there are some warnings (I don't know enough about cmake to judge how serious they are), but cmake still generates a Makefile. When I execute "make", I get:

    =============================
    christian@christian-white:~/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/build$ make
    [ 16%] Automatic MOC for target BorderWidgetQt
    
    AutoGen error
    -------------
      "/home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/QVTKOpenGLWidget.h"
    Could not read the header file: The file does not exist.
    
    CMakeFiles/BorderWidgetQt_autogen.dir/build.make:57: recipe for target 'CMakeFiles/BorderWidgetQt_autogen' failed
    make[2]: *** [CMakeFiles/BorderWidgetQt_autogen] Error 1
    CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/BorderWidgetQt_autogen.dir/all' failed
    make[1]: *** [CMakeFiles/BorderWidgetQt_autogen.dir/all] Error 2
    Makefile:83: recipe for target 'all' failed
    make: *** [all] Error 2
    christian@christian-white:~/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/build$ 
    ====================
    

    So it does not find the QVTKOpenGLWidget.h header file, I assume that is a bad sign. When I manually download that header file and put it in the source directory and repeat the make, I get:

    ==================
    christian@christian-white:~/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/build$ make
    [ 16%] Automatic MOC for target BorderWidgetQt
    [ 16%] Built target BorderWidgetQt_autogen
    [ 33%] Building CXX object CMakeFiles/BorderWidgetQt.dir/BorderWidgetQt.cxx.o
    /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/BorderWidgetQt.cxx: In constructor ‘BorderWidgetQt::BorderWidgetQt()’:
    /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/BorderWidgetQt.cxx:37:49: error: no matching function for call to ‘QVTKOpenGLWidget::SetRenderWindow(vtkNew<vtkGenericOpenGLRenderWindow>&)’
       this->qvtkWidget->SetRenderWindow(renderWindow);
                                                     ^
    In file included from /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/build/ui_BorderWidgetQt.h:19:0,
                     from /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/BorderWidgetQt.h:9,
                     from /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/BorderWidgetQt.cxx:1:
    /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/QVTKOpenGLWidget.h:90:8: note: candidate: void QVTKOpenGLWidget::SetRenderWindow(vtkGenericOpenGLRenderWindow*)
       void SetRenderWindow(vtkGenericOpenGLRenderWindow* win);
            ^~~~~~~~~~~~~~~
    /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/QVTKOpenGLWidget.h:90:8: note:   no known conversion for argument 1 from ‘vtkNew<vtkGenericOpenGLRenderWindow>’ to ‘vtkGenericOpenGLRenderWindow*’
    /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/QVTKOpenGLWidget.h:91:8: note: candidate: void QVTKOpenGLWidget::SetRenderWindow(vtkRenderWindow*)
       void SetRenderWindow(vtkRenderWindow* win);
            ^~~~~~~~~~~~~~~
    /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/QVTKOpenGLWidget.h:91:8: note:   no known conversion for argument 1 from ‘vtkNew<vtkGenericOpenGLRenderWindow>’ to ‘vtkRenderWindow*’
    /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/BorderWidgetQt.cxx:45:38: error: no matching function for call to ‘vtkActor::SetMapper(vtkNew<vtkPolyDataMapper>&)’
       sphereActor->SetMapper(sphereMapper);
                                          ^
    In file included from /usr/include/vtk-7.1/vtkActorCollection.h:32:0,
                     from /usr/include/vtk-7.1/vtkRenderer.h:39,
                     from /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/BorderWidgetQt.cxx:8:
    /usr/include/vtk-7.1/vtkActor.h:144:16: note: candidate: virtual void vtkActor::SetMapper(vtkMapper*)
       virtual void SetMapper(vtkMapper *);
                    ^~~~~~~~~
    /usr/include/vtk-7.1/vtkActor.h:144:16: note:   no known conversion for argument 1 from ‘vtkNew<vtkPolyDataMapper>’ to ‘vtkMapper*’
    /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/BorderWidgetQt.cxx:49:33: error: no matching function for call to ‘vtkRenderer::AddActor(vtkNew<vtkActor>&)’
       renderer->AddActor(sphereActor);
                                     ^
    In file included from /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/BorderWidgetQt.cxx:8:0:
    /usr/include/vtk-7.1/vtkRenderer.h:76:8: note: candidate: void vtkRenderer::AddActor(vtkProp*)
       void AddActor(vtkProp *p);
            ^~~~~~~~
    /usr/include/vtk-7.1/vtkRenderer.h:76:8: note:   no known conversion for argument 1 from ‘vtkNew<vtkActor>’ to ‘vtkProp*’
    /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/BorderWidgetQt.cxx:52:60: error: no matching function for call to ‘vtkRenderWindow::AddRenderer(vtkNew<vtkRenderer>&)’
       this->qvtkWidget->GetRenderWindow()->AddRenderer(renderer);
                                                                ^
    In file included from /usr/include/vtk-7.1/vtkOpenGLRenderWindow.h:29:0,
                     from /usr/include/vtk-7.1/vtkGenericOpenGLRenderWindow.h:31,
                     from /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/BorderWidgetQt.cxx:5:
    /usr/include/vtk-7.1/vtkRenderWindow.h:96:16: note: candidate: virtual void vtkRenderWindow::AddRenderer(vtkRenderer*)
       virtual void AddRenderer(vtkRenderer *);
                    ^~~~~~~~~~~
    /usr/include/vtk-7.1/vtkRenderWindow.h:96:16: note:   no known conversion for argument 1 from ‘vtkNew<vtkRenderer>’ to ‘vtkRenderer*’
    /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/BorderWidgetQt.cxx:56:24: error: no match for ‘operator=’ (operand types are ‘vtkSmartPointer<vtkBorderWidget>’ and ‘vtkNew<vtkBorderWidget>’)
       this->BorderWidget = bw;
                            ^~
    In file included from /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/BorderWidgetQt.h:4:0,
                     from /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/BorderWidgetQt.cxx:1:
    /usr/include/vtk-7.1/vtkSmartPointer.h:56:20: note: candidate: vtkSmartPointer<T>& vtkSmartPointer<T>::operator=(T*) [with T = vtkBorderWidget]
       vtkSmartPointer& operator=(T* r)
                        ^~~~~~~~
    /usr/include/vtk-7.1/vtkSmartPointer.h:56:20: note:   no known conversion for argument 1 from ‘vtkNew<vtkBorderWidget>’ to ‘vtkBorderWidget*’
    /usr/include/vtk-7.1/vtkSmartPointer.h:69:20: note: candidate: template<class U> vtkSmartPointer<T>& vtkSmartPointer<T>::operator=(const vtkSmartPointer<U>&) [with U = U; T = vtkBorderWidget]
       vtkSmartPointer& operator=(const vtkSmartPointer<U>& r)
                        ^~~~~~~~
    /usr/include/vtk-7.1/vtkSmartPointer.h:69:20: note:   template argument deduction/substitution failed:
    /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/BorderWidgetQt.cxx:56:24: note:   ‘vtkNew<vtkBorderWidget>’ is not derived from ‘const vtkSmartPointer<T>’
       this->BorderWidget = bw;
                            ^~
    In file included from /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/BorderWidgetQt.h:4:0,
                     from /home/christian/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/BorderWidgetQt.cxx:1:
    /usr/include/vtk-7.1/vtkSmartPointer.h:29:7: note: candidate: vtkSmartPointer<vtkBorderWidget>& vtkSmartPointer<vtkBorderWidget>::operator=(const vtkSmartPointer<vtkBorderWidget>&)
     class vtkSmartPointer: public vtkSmartPointerBase
           ^~~~~~~~~~~~~~~
    /usr/include/vtk-7.1/vtkSmartPointer.h:29:7: note:   no known conversion for argument 1 from ‘vtkNew<vtkBorderWidget>’ to ‘const vtkSmartPointer<vtkBorderWidget>&’
    /usr/include/vtk-7.1/vtkSmartPointer.h:29:7: note: candidate: vtkSmartPointer<vtkBorderWidget>& vtkSmartPointer<vtkBorderWidget>::operator=(vtkSmartPointer<vtkBorderWidget>&&)
    /usr/include/vtk-7.1/vtkSmartPointer.h:29:7: note:   no known conversion for argument 1 from ‘vtkNew<vtkBorderWidget>’ to ‘vtkSmartPointer<vtkBorderWidget>&&’
    CMakeFiles/BorderWidgetQt.dir/build.make:66: recipe for target 'CMakeFiles/BorderWidgetQt.dir/BorderWidgetQt.cxx.o' failed
    make[2]: *** [CMakeFiles/BorderWidgetQt.dir/BorderWidgetQt.cxx.o] Error 1
    CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/BorderWidgetQt.dir/all' failed
    make[1]: *** [CMakeFiles/BorderWidgetQt.dir/all] Error 2
    Makefile:83: recipe for target 'all' failed
    make: *** [all] Error 2
    christian@christian-white:~/InSync/Tmp/QVTKtest/BorderWall/BorderWidgetQt/build$
    ================
    

    So it does not find the implementation of QVTKOpenGLWidget.

    I installed Qt 5.9.5 and VTK-7.1 through the Ubuntu package manager, including any packages that seemed relevant.

    I would greatly appreciate your help in getting past this initial roadblock!

    Christian

    [edit: Added missing coding tags SGaist]


  • Lifetime Qt Champion

    How did you download the example ?

    As for VTK, did you install all VTK related development packages ?



  • Regarding downloading, the link that you sent me contained both a link to a .tar file (which I downloaded) and instruction (which I followed).
    Regarding VTK, yes I installed everything that seemed relevant, including

    vtk7
    libvtk7-dev
    libvtk7.1
    libvtk7.1-qt

    Best wishes,

    Christian


  • Lifetime Qt Champion



  • @SGaist
    No, that file is not on my system. I now installed all Ubuntu packages that contained "vtk" and "python" in their name but still don't have the file.

    Is this library the one that contains QVTKOpenGLWidget? Do you know which Ubuntu 18.04 package it is supposed to be in?

    Best wishes,

    Christian


  • Lifetime Qt Champion

    From a quick search it seems to be in python-vtk.

    I don't think so, but it's a least one error less on your list.



  • @SGaist
    Strange, I do have the package "python-vtk6" installed (the current version for Ubuntu 18.04) and get the errors I posted earlier. Also, looking at the files that are installed from "python-vtk6", there is no library "vtkOpenGLWidget.so". There are a number of libraries that sound related, including "vtkRenderingOpenGLPython.x86_64-linux-gnu.so" and "vtkRenderingQTPython.x86_64-linux-gnu.so".

    Thanks for your continuing help!
    Christian



  • @SGaist
    Any more thoughts?


  • Lifetime Qt Champion

    AFAIK, there's no specific library for just the VTKOpenGLWidget.

    By the way, how many versions of VTK do you have installed ?



  • Should be in the vtkGUISupportQt library.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.