[vtkusers] Newbie Needs example code for slider bars

Ashish Singh mrasingh at gmail.com
Fri Oct 13 13:32:29 EDT 2006


Thanks Anja. I am using visual studio 2005 as my IDE. I ran a simple
example. I clubbed the hello world example from qt and an image display
example from vtk together and then ran it using qmake. I wanted to make a
visual studio project so i ran the command:
'qmake -project -t vcapp -o helloworld.pro' <http://helloworld.pro>
this gave me a helloworld.pro file. I edited this file to include the path
etc and then ran qmake again. this gave me a .vcproj file which i opened in
visual studio and then build it there. Here I got all those errors.
The code I am using to test the working of vtk and qt together is as
follows:
-----
#include <QApplication>
#include <QPushButton>
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "conio.h"
#include "vtkDICOMImageReader.h"
#include "vtkImageViewer2.h"
#include "vtkRenderWindowInteractor.h"


    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);

        QPushButton hello("Hello world!");
        hello.resize(100, 30);

        hello.show();
      //  return app.exec();
  //  }


//int main( int argc, char *argv[] )
//{

  vtkDICOMImageReader *img1=vtkDICOMImageReader::New();
  img1->SetFileName("D:\\testimages\\IM_00001.dcm");

  vtkImageViewer2 * myviewer=vtkImageViewer2::New();
  myviewer->SetInput(img1->GetOutput());
  //myviewer->SetSize(720,540);
  myviewer->SetColorWindow(2000);
  myviewer->SetColorLevel(1500);
  myviewer->Render();

  vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(myviewer->GetRenderWindow());
  iren->Initialize();
  iren->Start();

  img1->Delete();
  myviewer->Delete();
  iren->Delete();

  return app.exec();
}
------
And my modified helloworld.pro file looks like this:
----
######################################################################
# Automatically generated by qmake (2.00a) Fri Oct 13 12:20:39 2006
######################################################################

TEMPLATE = vcapp
TARGET +=
DEPENDPATH += .
LIBS += C:\vtk-5.0.2\VTKBINARIES\bin\debug\vtkRendering.lib
INCLUDEPATH += .;C:\vtk-5.0.2\VTKSOURCE\GRAPHICS;C:\vtk-
5.0.2\VTKSOURCE\FILTERING;C:\vtk-5.0.2\VTKSOURCE\COMMON;C:\vtk-
5.0.2\VTKBINARIES;C:\vtk-5.0.2\VTKSOURCE\RENDERING;C:\vtk-5.0.2\VTKSOURCE\IO


# Input
SOURCES += helloworld.cpp
-------
Am I missing something? Plz. help.

Thanks,
Ashish


On 10/13/06, Anja Ende <anja.ende at googlemail.com> wrote:
>
> Hi Ashish,
>
> LD_LIBRARY_PATH only tells where to look for the dynamic libraries (DLLs
> on windows).
>
> What development environment are you using? Did you simply run qmake on
> your pro file and then make or are you using an IDE?
>
> Unfortunately, I am not a development machine now. But if it does not
> work, I will try to send a simple example tomorrow.
>
> Cheers,
> Anja
>
> On 13/10/06, Ashish Singh <mrasingh at gmail.com> wrote:
> >
> > Thanks Anja. But I am still stuck. Can you send me a simple example
> > maybe a cone example with something like a push button along with the pro
> > file, using both vtk and qt?
> >
> > As you suggested I set the lib path in the .pro file and the include
> > path to my vtk parent directory. But now it says cannot open include file
> > vtkconesource.h, if I add the path to this file it comes up with another
> > file...and another and another...
> > I get 5-6 such errors and if I include the path to all of them, I get a
> > fatal error:363 unresolved externals.
> > What did i miss? what is the LD_LIBRARY_PATH in your example? I didnt do
> > that part.
> >
> > Thanks,
> > Ashish
> >
> >
> > On 10/13/06, Anja Ende < anja.ende at googlemail.com> wrote:
> > >
> > > Hi Ashish,
> > >
> > > In the project PRO file (this is used when you run qmake) command, you
> > > will need to specify where the vt include and lib files are.
> > >
> > > Below, I am attaching the relevant sections from my PRO file. As you
> > > can see the LIBS directive tells QT the vtk libs I am using in my project
> > > and the INCLUDEPATH also includes the path to the vtk includes.
> > >
> > > LIBS += -lvtkWidgets \
> > > -lQVTK \
> > > -lvtktiff \
> > > -lvtkjpeg \
> > > -lvtkexpat \
> > > -lvtkMPEG2Encode \
> > > -lvtkIO \
> > > -lvtkRendering \
> > > -lvtkGraphics \
> > > -lvtkImaging \
> > > -lvtkftgl \
> > > -lvtkfreetype \
> > > -lvtkFiltering \
> > > -lvtkCommon \
> > > -lvtksys \
> > > -lvtkDICOMParser \
> > > -lXt \
> > > -lvtkpng \
> > > -lvtkzlib
> > >
> > > INCLUDEPATH += ../src \
> > > /usr/local/include/vtk-5.0
> > >
> > > In addition you must export the QTDIR and PATH variables and set the
> > > LD_LIBRARY_PATH . In Linux, the best place is the .bashrc file. I am not
> > > sure about windows but probably it is the environment variables.
> > >
> > > My .bashrc file looks like:
> > >
> > > export QTDIR=/usr/local/Trolltech/Qt-4.1.4
> > > export QTDIR
> > >
> > > export PATH=$PATH:/usr/local/Trolltech/Qt-4.1.4/bin/
> > > export PATH
> > > export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
> > >
> > >
> > > I hope this helps you.
> > >
> > > Cheers,
> > > Anja
> > >
> > > On 13/10/06, Ashish Singh <mrasingh at gmail.com> wrote:
> > > >
> > > > Even, I want to make a slider in my vtk application. I was planning
> > > > to use Qt for that, but for some reason I cannot get Qt to run with vtk. How
> > > > are you doing it, Anja? I have Qt 4.1.4 and VTK 5.0.2 installed on
> > > > my workstation (windows xp pro x64). Both of them are running independently
> > > > but I don't know how to use them together in the same application. How did
> > > > you configure them?
> > > >
> > > > Thanks,
> > > > Ashish
> > > >
> > > > On 10/13/06, Anja Ende < anja.ende at googlemail.com> wrote:
> > > >
> > > > > Hi Spencer,
> > > > >
> > > > > What GUI framework are you using for displaying the sliders? This
> > > > > should be completely independent from vtk.
> > > > >
> > > > > I use Qt and use QSlider and it works fine.
> > > > >
> > > > > Cheers,Anja
> > > > >
> > > > > _______________________________________________
> > > > > This is the private VTK discussion list.
> > > > > Please keep messages on-topic. Check the FAQ at:
> > > > > http://www.vtk.org/Wiki/VTK_FAQ
> > > > > Follow this link to subscribe/unsubscribe:
> > > > > http://www.vtk.org/mailman/listinfo/vtkusers
> > > > >
> > > > >
> > > > >
> > > >
> >
>
>
> --
> Cheers,
>
> Anja
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061013/55c033f8/attachment.htm>


More information about the vtkusers mailing list