‘vtkEventQtSlotConnect’ does not name a type
-
I am building a project with cmake .
The project is to read DICOM by vtk.
I meet a error: ‘vtkEventQtSlotConnect’ does not name a type.
Here is my code ```
//ReadDICOM.cpp
#include "ReadDICOMQt.h"
#include "ui_ReadDICOMQt.h"
#include <QFileDialog>ReadDICOMQt::ReadDICOMQt(QWidget *parent) : QMainWindow(parent), ui(new Ui::ReadDICOMQt) {
ui->setupUi(this);
reader = vtkSmartPointer<vtkDICOMImageReader>::New();
viewer = vtkSmartPointer<vtkImageViewer>::New();m_Connections = vtkEventQtSlotConnect::New(); m_Connections->Connect(m_QVTKWidget->GetRenderWindow()->GetInteractor(), vtkCommand::MouseMoveEvent, this, SLOT(updateCoords(vtkObject*)));//vtkNew<vtkGenericOpenGLRenderWindow> renderWindow;
//vtkNew<vtkRenderer> renderer;
//vtkNew<vtkImageSlice> imageSlice;
//vtkNew<vtkImageResliceMapper> mapper;
//vtkNew<vtkInteractorStyleImage> interactorStyle;
}ReadDICOMQt::~ReadDICOMQt() {
delete ui;
}void ReadDICOMQt::openDICOMFile() {
QString fileNameDICOM = QFileDialog::getOpenFileName(this, tr("Select DICOM File"), QDir::currentPath());
drawDICOMImage(fileNameDICOM.toUtf8().constData());
}
void ReadDICOMQt::updateCoords(int obj){
// 获取交互器
vtkRenderWindowInteractor iren = vtkRenderWindowInteractor::SafeDownCast(obj);// 获取鼠标的当前位置 int event_pos[2]; iren->GetEventPosition(event_pos); QString str; str.sprintf("x=%d : y=%d", event_pos[0], event_pos[1]); m_StatusBar->showMessage(str);}
void ReadDICOMQt::drawDICOMImage(std::string fileDICOM) {
// 获取DICOM图像的文件夹
reader->SetFileName(fileDICOM.c_str());
reader->Update();
// 将输入与viewer结合起来
viewer->SetInputConnection(reader->GetOutputPort());
// 将widght 链接到viewer
ui->qvtkWidget->SetRenderWindow(viewer->GetRenderWindow());
//向viewer添加interactor
viewer->SetupInteractor(ui->qvtkWidget->GetInteractor());
// init
viewer->Render();// 更新GUI label
ui->labelFileName->setText(QString::fromStdString(fileDICOM));}
void ReadDICOMQt::on_buttonOpenFile_clicked() {
openDICOMFile();
}
//ReadDICOM.h
#ifndef READDICOMQT_H
#define READDICOMQT_H#include <QMainWindow>
#include <vtkSmartPointer.h>
#include <vtkDICOMImageReader.h>
#include <vtkImageViewer.h>namespace Ui {
class ReadDICOMQt;
}class ReadDICOMQt : public QMainWindow {
Q_OBJECTpublic:
explicit ReadDICOMQt(QWidget *parent = 0);
~ReadDICOMQt();private slots:
void openDICOMFile();
void drawDICOMImage(std::string fileDICOM);
void on_buttonOpenFile_clicked();
void updateCoords(vtkObject* obj);private:
Ui::ReadDICOMQt ui;
vtkSmartPointer<vtkDICOMImageReader> reader;
vtkSmartPointer<vtkImageViewer> viewer;
vtkEventQtSlotConnect m_Connections;
};
#endif // READDICOMQT_HThe error occurred when I make the makefile -
Hi and welcome to devnet,
You are missing the include that defines that class. See its documentation.
-
Hi and welcome to devnet,
You are missing the include that defines that class. See its documentation.
-
Hi and welcome to devnet,
You are missing the include that defines that class. See its documentation.
-
No, it's unrelated to cmake. You need to include the header in the file where you use an instance of the class.