Visualize VTK elements in Qt GUI from mex-file

Version 1.0.0.0 (3.66 KB) by Mimi
Demo codes for creating a Qt GUI in mex file and for visualization of VTK elements with QVTKWidget
76 Downloads
Updated 23 Feb 2016

View License

I required own Qt slots within a mex-file, so a solution was needed to use own slots without the necessity of using MOC. Therefore the virtual slots of Qt classes are helpful. The keyword 'virtual' enables the object orientated concept of dynamic binding. Dynamic binding is a concept in which the function being called upon an object, is looked up by name at runtime. Functions of a superclass which are declared as virtual, can get overriden in derived classes.
This is not an example of clean coding, but it works. Maybe someone'll find it useful for playing around. ;-)
NoMoc.cpp is a demo for creating a Qt GUI in a mex file
demoqtvtk.cpp is a demo for visualization of VTK elements with QVTKWidget, the white line is modified from http://www.vtk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/Line :-P
calldemo.m creates the mexfiles
There are precompiled versions of Qt available.
I work with Qt 5.4 and MSVS 2016 64bit.
I need to copy the directories from Qt/include into my Matlab.../extern/include directory and the files QWidget and QWidget.h. (Both are contained in the Qt/include/QtWidgets directory, but I had problems adressing them.)

For using VTK with Qt you have to build VTK with Qt support. You'll get QVTKWidgetPlugin.dll. I need to copy it into my Matlab workspace together with the *.dlls from Qt/bin and the Qt/plugins/platforms directory.

For easier building of the mex-file I copied the *.lib files from Qt/lib into my VTK/lib directory. So calldemo.m loads everything automatically.

Cite As

Mimi (2026). Visualize VTK elements in Qt GUI from mex-file (https://uk.mathworks.com/matlabcentral/fileexchange/55595-visualize-vtk-elements-in-qt-gui-from-mex-file), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Search Path in Help Center and MATLAB Answers
Tags Add Tags
Version Published Release Notes
1.0.0.0

spelling....