[vtkusers] QVTKWidget HelloWorld example?

Carlos Capdepon carlos.capdepon at gmail.com
Tue Apr 4 18:36:54 EDT 2006


QVTKWidget OK.

QVTKWidgetPlugin link error. WHY?¿?


I have tried with this CMakelists.txt

CMAKE_MINIMUM_REQUIRED(VERSION 2.0)
# Project customization.
SET(PROJECT_NAME "QtHelloWorld")
SET(EXECUTABLE_NAME "qtHW")
SET(PROJECT_MAJOR_VERSION 0)
SET(PROJECT_MINOR_VERSION 1)
SET(PROJECT_BUILD_VERSION "alpha")
SET(${PROJECT_NAME}_SOURCE_MAIN_FILE helloworld.cxx)
# Project's name.
PROJECT(${PROJECT_NAME})
SET(PROJECT_VERSION
"${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_BUILD_VERSION}")
MESSAGE(STATUS "Building ${PROJECT_NAME} v${PROJECT_VERSION}.")

# Find Visualization Toolkit 5.x
FIND_PACKAGE(VTK REQUIRED)
IF(VTK_FOUND)
 INCLUDE(${VTK_USE_FILE})
 MESSAGE(STATUS "Visualization Toolkit found.")
ELSE(VTK_FOUND)
 MESSAGE(FATAL_ERROR "Cannot build ${PROJECT_NAME} without VTK.  Please set
VTK_DIR.")
ENDIF(VTK_FOUND)
# Find Qt 4.x
FIND_PACKAGE(QT4 REQUIRED)
IF(QT_FOUND)
 INCLUDE(${QT_USE_FILE})
 MESSAGE(STATUS "Qt4 found.")
ELSE(QT_FOUND)
 MESSAGE(FATAL_ERROR "Cannot build ${PROJECT_NAME} without Qt4.")
ENDIF(QT_FOUND)
# Use the include path and library for Qt that is used by VTK.
#INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR}
${QT_QTCORE_INCLUDE_DIR})
# Executable's name and sources.
ADD_EXECUTABLE(${EXECUTABLE_NAME} ${${PROJECT_NAME}_SOURCE_MAIN_FILE})
# Link the executable to the vtkRendering library.
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME}
  QVTK
  ${QT_LIBRARIES}
  vtkRendering
  vtkGraphics
  vtkIO
  vtkCommon
)

I don't know if it this Cmakelists.txt is incomplete or bad, but QVTKWidget
goes with my helloworld.cxx

#include <QApplication.h>
#include <QVTKWidget.h>
#include <vtkSphereSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>

int main( int argc, char **argv )
{
    QApplication app( argc, argv );
  app.aboutQt();
 QVTKWidget widget;
  widget.resize(640,384);
#if QT_VERSION < 0x040000
 app.setMainWidget(&widget);
#endif
 vtkSphereSource *esferaCircunscrita = vtkSphereSource::New();
  esferaCircunscrita->SetRadius(1.0);
  esferaCircunscrita->SetThetaResolution(36);
  esferaCircunscrita->SetPhiResolution(20);
 vtkPolyDataMapper *esferaCircunscritaMapper = vtkPolyDataMapper::New();
  esferaCircunscritaMapper->SetInput(esferaCircunscrita->GetOutput());
 vtkActor *esferaCircunscritaActor = vtkActor::New();
  esferaCircunscritaActor->SetMapper(esferaCircunscritaMapper);
 vtkRenderer *renderer = vtkRenderer::New();
  renderer->SetBackground(0.4,0.6,0.8);
  renderer->SetViewport(0.0,0.0,1.0,1.0);
  renderer->AddActor(esferaCircunscritaActor);
 vtkRenderWindow *renderWindow = vtkRenderWindow::New();
  renderWindow->AddRenderer(renderer);
  renderWindow->DoubleBufferOn();
  renderWindow->SetStereoTypeToDresden();
  widget.SetRenderWindow(renderWindow);
  widget.show();
  app.exec();
    return 0;
}

--
Un saludo,
"Carlos Capdepón" <carlos.capdepon at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060405/16cf8b9b/attachment.htm>


More information about the vtkusers mailing list