[vtkusers] QWidget:Must construct a QApplication before a QPaintDevice

Leonid Dulman leonid_dulman at yahoo.co.uk
Mon Aug 15 03:09:37 EDT 2011


Hi to All 
In next Example 
#include "qmainwindow.h"
 #include "qapplication.h"

 #include <QVTKWidget.h>
 #include <QVTKApplication.h>

 #include <vtkRenderWindow.h>
 #include <vtkRenderer.h>
 #include <vtkTextSource.h>
 #include <vtkVectorText.h>
 #include <vtkPolyDataMapper.h>
 #include <vtkActor.h>

 int main( int argc, char **argv )
 {
  QVTKApplication app(argc,argv);
  QMainWindow *mainWindow = new QMainWindow;
   mainWindow->setFixedSize(640,360);

  QVTKWidget *widget = new QVTKWidget;
   mainWindow->setCentralWidget(widget);

  vtkTextSource *text = vtkTextSource::New();
   text->SetText("Hello World!");
   text->BackingOff();
  vtkVectorText *vectorText = vtkVectorText::New();
   vectorText->SetText("QVTKWidget");
  vtkPolyDataMapper *textMapper = vtkPolyDataMapper::New();
   textMapper->SetInput(text->GetOutput());
  vtkPolyDataMapper *vectorTextMapper = vtkPolyDataMapper::New();
   vectorTextMapper->SetInput(vectorText->GetOutput());
  vtkActor *textActor = vtkActor::New();
   textActor->SetMapper(textMapper);
  vtkActor *vectorTextActor = vtkActor::New();
   vectorTextActor->SetMapper(vectorTextMapper);
  vtkRenderer *renderer = vtkRenderer::New();
   renderer->SetBackground(0.4,0.6,0.8);
   renderer->AddActor(textActor);
   renderer->AddActor(vectorTextActor);
  vtkRenderWindow *renderWindow = vtkRenderWindow::New();
   renderWindow->AddRenderer(renderer);
   renderWindow->SetStereoTypeToDresden();

  widget->SetRenderWindow(renderWindow);
  mainWindow->show();
  app.aboutQt();
     return app.exec();
 }

I have got massage "QWidget:Must construct a QApplication before a QPaintDevice" only in Windows 7 SP1, in Windows XP and linux I have no any problems

My installation is
Qt 4.7.3
VTK 5.9.0 (from git)
Thank you. Leonid  





More information about the vtkusers mailing list